Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode debugger can not import queue due to shadowing

When I try to run any python code in debug mode using VScode, I got an error message saying:

42737 -- /home/<username>/Desktop/development/bopi/experiment_handler.py .vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/launcher 4
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module>
    from debugpy.server import cli
  File "/home/<username>/.vscode-server/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 "/home/<username>/.vscode-server/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 "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/<username>/.vscode-server/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 "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 97, in <module>
    import queue as _queue;    verify_shadowed.check(_queue, ['Queue', 'LifoQueue', 'Empty', 'Full', 'deque'])
  File "/home/<username>/.vscode-server/extensions/ms-python.python-2022.4.0/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydev_bundle/_pydev_saved_modules.py", line 75, in check
    raise DebuggerInitializationError(msg)
_pydev_bundle._pydev_saved_modules.DebuggerInitializationError: It was not possible to initialize the debugger due to a module name conflict.

i.e.: the module "queue" could not be imported because it is shadowed by:
/home/<username>/.local/lib/python2.7/site-packages/queue/__init__.pyc
Please rename this file/folder so that the original module from the standard library can be imported.

Deleting the init.pyc and init.py resulting with an error message about missing queue import.

like image 568
onurtore Avatar asked Mar 05 '26 23:03

onurtore


1 Answers

Downgrading my Python extension in Visual Studio Code to v2022.2.1924087327 worked for me.

Elevating @Onur Berk's comment below as part of the answer:

Its is very easy to downgrade the python extension, just click 'extensions' and find the Python extension and select it. Rather than clicking 'uninstall' click the arrow next to it, this will give you an option to install another version

like image 135
Devang Hathalia Avatar answered Mar 08 '26 12:03

Devang Hathalia



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!