无法确定 sys.argv 的模块路径错误 – 每个 Python 程序都返回此错误。

huangapple go评论80阅读模式
英文:

Error determining module path for sys.argv - every python program returns this error

问题

这个错误是在我尝试安装 plotly.graph_objects 后开始出现的,现在无论我运行任何 Python 程序,都会弹出这个错误。我现在已经卸载了这个模块,但错误仍然存在。

即使尝试执行一个 print 语句,也会显示以下错误:

E+00000.063: 无法确定 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)
英文:

This error started happening after I tried to install plotly.graph_objects and now everytime I run any python program at all this error pops up. I have uninstalled the module now but the errors stays.

Even trying to execute a print statement,
This is the error it shows:

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)

答案1

得分: 2

找到解决方法了!如果你在使用VS Code,在左上角的“编辑”下方有一个下拉框,里面有一个绿色三角形和写着“Python”的字样,选择它。如果它显示的是“Python: Module”,改成“Python: File”就可以了。这是我解决问题的方法。花了3天才解决!

英文:

FOUND THE FIX! if you are using vs code, near the top left underneath 'Edit' there is a dropdown box with a green triangle and written 'Python' select that if it's on 'Python: Module' change it to 'Python: File' this is what fixed it for me. 3 days it took!

huangapple
  • 本文由 发表于 2023年4月19日 18:38:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053540.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定