VSCode 由于阴影,调试器无法导入队列
VSCode debugger can not import queue due to shadowing
当我尝试使用 VScode 在调试模式下 运行 任何 python 代码时,我收到一条错误消息:
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.
正在删除 init.pyc 和 init.py,导致出现有关缺少队列导入的错误消息。
将 Visual Studio 代码中的 Python 扩展降级到 v2022.2.1924087327
对我有用。
提升 作为答案的一部分:
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
当我尝试使用 VScode 在调试模式下 运行 任何 python 代码时,我收到一条错误消息:
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.
正在删除 init.pyc 和 init.py,导致出现有关缺少队列导入的错误消息。
将 Visual Studio 代码中的 Python 扩展降级到 v2022.2.1924087327
对我有用。
提升
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