Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: No module named _thread

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

print('test')

returns: ImportError: No module named _thread

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
like image 794
박성수 Avatar asked Feb 02 '26 08:02

박성수


1 Answers

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

like image 129
HDJEMAI Avatar answered Feb 03 '26 23:02

HDJEMAI



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!