我注意到我的激活虚拟环境在VS Code终端中停止工作。
我的settings.json看起来像这样:
{
"python.unitTest.unittestArgs": [
"-v",
"-s",
"./documenttagging/tests",
"-p",
"test_*.py"
],
"python.unitTest.pyTestEnabled": false,
"python.unitTest.nosetestsEnabled": false,
"python.unitTest.unittestEnabled": true,
"python.pythonPath": "env\\Scripts\\python.exe",
"python.terminal.activateEnvironment": true
}
以前我的virtualenv自动激活并且工作正常。看起来它现在也在终端中被激活,但是当运行pip列表时,我看到它是使用的系统Python安装。
尝试通过运行以下命令手动激活VS Code终端中的环境时:
env/Scripts/activate
我希望环境能够被激活。但是当运行“pip list”时,很明显它正在使用Python的系统安装。当我在cmd终端中运行相同的命令时它工作正常,“pip list”表示使用正确的包激活了正确的环境。
它曾经工作正常,但突然停止工作
注意:当我在vscode中运行调试器时,选择并执行正确的环境。
我的设置:
知道什么可能是错的吗?
你能尝试以下方法吗?
"python.pythonPath": "${workspaceFolder}/env/Scripts/python.exe"
要么
"python.pythonPath": "c:\\your\\entire\\path\\env\\Scripts\\python.exe"
您可以使用此命令激活
source env/Scripts/activate