python - 当我输入 source env/bin/activate 时如何在 vs 代码编辑器中激活 virtualenv 它没有激活
问题描述
注意:我在window 10中新安装了vs代码
PS C:\Users\admin\Desktop\Kiit Project\django-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-ecommerce)并运行env\Scripts\activate
。这应该做的工作。
但是,在 VScode 中,您可能必须编辑settings.json
文件夹中存在的.vscode
文件并添加以下内容:
{
...
"python.pythonPath": "C:\Users\admin\Desktop\Kiit Project\django-ecommerce\env\bin\python",
...
}
如果您无法找到上述settings.json
文件,只需按Ctrl+Shift+P
并键入python Select Interpreter
并按Enter
。然后,您将看到一个.vscode
包含您的settings.json
文件的目录。
您可以编辑此文件,但是您想更改用于 VScode 实例的 Python 解释器。
推荐阅读
- python - Web Scraping的分页需要帮助>
- python - 为什么我在使用 pandas read_gbq 时收到错误“禁止访问:403 访问被拒绝:BigQuery BigQuery:权限被拒绝,同时使用pandas read_gbq”
- r-exams - Exams2pdf 乳胶错误!缺少 $ 插入
- ios - 如何在 iOS 中实现 TextKit 中段落的自定义布局
- zsh - 在 zsh 上使用双引号时,rsync 服务器自动完成对文件不起作用
- javascript - 使用 id 更新 mongoose 数组中的嵌套对象
- java - Java中的随机问题
- javascript - 如何在 Reactjs 中回调函数
- javascript - 三元运算符双引号
- talend - 工作区已在使用问题