Home > other >  ImportError: No module named _thread
ImportError: No module named _thread

Time:04-01

Compiling python2 in vscode gives an error. But when I compile python3 it succeeds.

print('test')

retu

PS C:\source>  c:; cd 'c:\source'; & 'C:\Python27\python.exe' 'c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy\launcher' '52037' '--' 'c:\source\test.py' 
Traceback (most recent call last):
  File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy\__main__.py", line 43, in <module>
    from debugpy.server import cli
  File "c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy/../debugpy\server\__init__.py", line 9, in <module>
    import debugpy._vendored.force_pydevd  # noqa
  File "c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy/../debugpy\_vendored\force_pydevd.py", line 37, in <module>
    pydevd_constants = import_module('_pydevd_bundle.pydevd_constants')
  File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
    __import__(name)
  File "c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_constants.py", line 362, in <module>  
    from _pydev_bundle._pydev_saved_modules import thread, threading
  File "c:\Users\keinblue\.vscode\extensions\ms-python.python-2022.4.0\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydev_bundle\_pydev_saved_modules.py", line 94, in <module>
    import _thread as thread;    verify_shadowed.check(thread, ['start_new_thread', 'start_new', 'allocate_lock'])
ImportError: No module named _thread

CodePudding user response:

There is an issue with the vscode python extension version 2022.4.0

just downgrade to version 2022.2.1924087327 and it will work as it works for me now

Just follow these steps:

  • Go to extensions.
  • Click on Gear Icon for the installed extension
  • Click on Install Another Version
  • select the version you wish to install

enter image description here

CodePudding user response:

I think its the VS Code Python Extension. In VS Code select the Python Extension and select the Uninstall dropdown to install a previous version, the 2022.2.xxx fixed this issue.install previous version

  • Related