在 python 中切换到虚拟环境后尝试 运行 编码时,VS Code 总是出错

VS Code always gives error when trying to run code after switching to virtual env in python

错误:

PS C:\Users\Prashant(Gaz)\fieldrocket-pygame\fieldrocket> & c:/Users/Prashant(Gaz)/fieldrocket-pygame/fieldrocket/pyfr/Scripts/Activate.ps1
Gaz : The term 'Gaz' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if 
a path was included, verify that the path is correct and try again.
At line:1 char:21
+ & c:/Users/Prashant(Gaz)/fieldrocket-pygame/fieldrocket/pyfr/Scripts/ ...
+                     ~~~
    + CategoryInfo          : ObjectNotFound: (Gaz:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 
PS C:\Users\Prashant(Gaz)\fieldrocket-pygame\fieldrocket> 

所以我通过 cmd 创建了一个虚拟环境,然后打开了 vs code,试图将解释器切换到 venv,但是当我点击新终端或 运行来自右键单击菜单的代码....如果我将命令用作字符串,这显然有效所以为什么 vs 代码这样做请帮助...

如果我手动激活 venv 它工作得很好,但我不能快速 运行 代码因为这个,我知道为什么有时会发生这种情况....一些作品之前我正在使用 django 并且从未有过一直使用 venv 时完全没有这个问题

编辑:命令不是我输入的,我只是打开了一个新终端,即使在手动激活 venv 之后,如果我重新打开一个新终端,它也会给出同样的错误

您应该将您的虚拟环境移动到其他地方,该路径不包含 ()

更新:

如果你想避免在创建新终端时自动激活虚拟环境。您可以将此添加到您的 settings.json 文件中:

"python.terminal.activateEnvironment": false,