(我怀疑这与我在外部usb驱动器上创建了一个虚拟环境有关,但我不知道如何解决这个问题,因为它昨晚运行良好(
当我第二天尝试调试VS代码python脚本时,它突然不起作用了。一切都很好,我保存了sccript然后就睡着了。第二天醒来,重新启动VS代码,突然脚本不再运行。由于某种原因,我甚至无法在交互菜单中选择VS代码中的环境。
以下是一个名为"setup.py";出于某种原因:
Exception has occurred: AssertionError (note: full exception trace is shown but execution is paused at: <module>)
b'No module named Crn'
File "C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3setup.py", line 109, in get_description
assert not stderr, stderr
File "C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3setup.py", line 337, in main
long_description=get_description(),
File "C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3setup.py", line 442, in <module>
main()
File "<string>", line 1, in <module> (Current frame)
终端窗口输出的内容如下:
& e:/E_ProgramData/Python/Python391/Othello/Scripts/Activate.ps1
& : File E:E_ProgramDataPythonPython391OthelloScriptsActivate.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at
https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:3
+ & e:/E_ProgramData/Python/Python391/Othello/Scripts/Activate.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
和
ERROR: Command errored out with exit status 1:
command: 'e:E_ProgramDataPythonPython391OthelloScriptspython.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Yaseen Ahammed\AppData\Local\Temp\pip-install-qafef280\psutil_3bb3fb77c9f54c76acc10f29c92e88d3\setup.py'"'"'; __file__='"'"'C:\Users\Yaseen Ahammed\AppData\Local\Temp\pip-install-qafef280\psutil_3bb3fb77c9f54c76acc10f29c92e88d3\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:UsersYaseen AhammedAppDataLocalTemppip-pip-egg-info-xonu1kkr'
cwd: C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3
Complete output (9 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
main()
File "C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3setup.py", line 337, in main
long_description=get_description(),
File "C:UsersYaseen AhammedAppDataLocalTemppip-install-qafef280psutil_3bb3fb77c9f54c76acc10f29c92e88d3setup.py", line 109, in get_description
assert not stderr, stderr
AssertionError: b'No module named Crn'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
我不明白发生了什么变化,也不明白为什么VS Code突然不想再工作了。
我确实在我的外部USB硬盘上创建了一个新的虚拟环境;"奥赛罗";你可以看到它正在尝试访问,但无法访问。奇怪的是,它昨晚工作得很好,所以我不明白为什么它在重新启动VS Code后停止了工作。
我注意到的另一个新事物是VS Code Python解释器不再说";"奥赛罗";当我从我在外部驱动器上创建的环境文件夹中选择exe时,它在Python版本名旁边说Othello,表示它昨晚选择了正确的环境。
提前谢谢。
尝试:
-
添加或确保已正确添加
PYTHONPATH
Windows,请遵循此StackOverflow问题 -
如果没有修复,请确保遵循以下文章:
-
在VS代码中使用Python环境
-
StackOverflow如何在VS代码中为Python设置虚拟环境?
-
的开发