注意:我在窗口 10 中新安装了 vs 代码
PS C:UsersadminDesktopKiit Projectdjango-ecommerce> source env/bin/activate
source : The term 'source' 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.
+ source env/bin/activate
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (source:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
假设你的虚拟环境的名称是env
,你可以简单地进入它所在的目录(我认为C:\Users\admin\Desktop\Kiit Project\django-commerce在你的例子中(并运行envScriptsactivate
。这应该可以完成工作。
但是,在 VScode 中,您可能必须编辑文件夹中存在的settings.json
文件.vscode
并添加以下内容:
{
...
"python.pythonPath": "C:UsersadminDesktopKiit Projectdjango-ecommerceenvbinpython",
...
}
如果您找不到上面提到的settings.json
文件,只需按Ctrl+Shift+P
并键入python Select Interpreter
并按Enter
.然后,您将看到一个包含settings.json
文件的.vscode
目录。
您可以编辑此文件,但您希望更改用于 VScode 实例的 Python 解释器。