安装plotly.graph_objects后所有Python程序均报路径错误求助
问题
安装plotly.graph_objects后,运行任何Python程序(包括简单print语句)都会触发Error determining module path for sys.argv错误,卸载模块后问题依旧。报错详情:
E+00000.063: Error determining module path for sys.argv Traceback (most recent call last): File "c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../../debugpy\launcher/../../debugpy/..\debugpy\server\cli.py", line 296, in run_module spec = find_spec(options.target) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\importlib\util.py", line 94, in find_spec parent = __import__(parent_name, fromlist=['__path__']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ModuleNotFoundError: No module named 'plotly==5' Stack where logged: File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\User\AppData\Local\Programs\Python\Python311\Lib\runpy.py", line 88, in _run_code exec(code, run_globals) File "c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../../debugpy\launcher/../../debugpy\__main__.py", line 39, in <module> cli.main() File "c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../../debugpy\launcher/../../debugpy\..\debugpy\server\cli.py", line 430, in main run() File "c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../../debugpy\launcher/../../debugpy\..\debugpy\server\cli.py", line 300, in run_module log.swallow_exception("Error determining module path for sys.argv") File "c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy\adapter/../../debugpy\launcher/../../debugpy\..\debugpy\common\log.py", line 215, in swallow_exception _exception(format_string, *args, **kwargs)
解决步骤
- 修正VS Code调试配置:打开项目下的
.vscode/launch.json,检查program字段值。如果之前错误设置为plotly==5这类带版本号的模块名,改为实际要运行的脚本路径,比如${file}表示当前打开的文件。 - 重置Python环境选择:点击VS Code左下角的Python解释器版本,重新选择正确的本地Python环境,确保环境未关联残留的模块配置。
- 清理调试工具缓存:删除
c:\Users\User\.vscode\extensions\ms-python.python-2023.4.1\pythonFiles\lib\python\debugpy目录下的临时缓存文件,或者直接卸载并重装VS Code的Python扩展。 - 彻底清理模块残留:打开命令行执行
pip list查看是否还有plotly相关条目,若有则运行pip uninstall plotly完全卸载,同时手动删除Python安装目录下site-packages文件夹中所有plotly相关的文件和文件夹。
内容的提问来源于stack exchange,提问作者64 bit
相关产品推荐
相关产品推荐

