[英]Mistake in setup python virtualEnv in visual-studio-code
Trying to setup Visual-Studio-Code and running into issues configuring virtualEnv properly. 尝试设置Visual Studio代码,并遇到配置virtualEnv的问题。 Read everything i could find online and tried different solutions: none worked so far. 阅读我可以在网上找到的所有内容,并尝试使用不同的解决方案:到目前为止,没有一种方法有效。 MAYBE i am just not getting the documentation and everyone else gets it. 也许我只是没有得到文档,其他人都得到了。
oauth2client
exists. 证明virtualEnv以及软件包oauth2client
存在。 oauth2client
can't be found. oauth2client
。 As you can see in the corner the Python interpreter was rightfully found. 正如您在拐角处看到的那样,正确找到了Python解释器。 I hope that one of you guys can spot my mistake. 我希望你们中的一个能发现我的错误。
Update: 更新:
So thanks to mattmc3 i figured it out. 因此,感谢mattmc3,我弄清楚了。 Was using the "Code Runner" Plugin for running the python code. 正在使用“代码运行器”插件运行python代码。 I missed setting up the right Interpreter for this plugin - used still the default one. 我错过了为此插件设置正确的解释器的机会-仍然使用默认解释器。
Your final screenshot indicates that you are using your venv
properly, which you named "py3". 最后的屏幕快照表明您正在正确使用venv
,并将其命名为“ py3”。 There are lots of ways to launch your Python script from VSCode: 有很多方法可以从VSCode启动Python脚本:
Based on the back-and-forth comments we exchanged, it appears that you did not launch using any of these standard methods, which could explain why your venv is not being picked up. 根据我们交换的来回评论,您似乎没有使用这些标准方法中的任何一种来启动,这可以解释为什么您的静脉未被拾取。
Here is the stepbystep how to create the Virtual environment in Visual Studio Code folder: I used Powershell (Administrator mode): 这是如何在Visual Studio Code文件夹中创建虚拟环境的分步说明:我使用了Powershell(管理员模式):
1. I create a VSCode folder - "D:\\Code_Python_VE" where I want to create Virtual environment. 1.我创建一个VSCode文件夹-“ D:\\ Code_Python_VE”,在其中创建虚拟环境。
2. Next I type the command - "pip3 install virtualenv". 2.接下来,我键入命令-“ pip3 install virtualenv”。 (D:\\Code_Python_VE> pip3 install virtualenv ) 3. D:\\Code_Python_VE> python3 -m venv project_env (D:\\ Code_Python_VE> pip3 install virtualenv)3. D:\\ Code_Python_VE> python3 -m venv project_env
4. D:\\Code_Python_VE>project_env\\Scripts\\activate.bat 4. D:\\ Code_Python_VE> project_env \\ Scripts \\ activate.bat
5. D:\\Code_Python_VE> ls - This will list a new directory "project_env". 5. D:\\ Code_Python_VE> ls-这将列出一个新目录“ project_env”。
6. D:\\Code_Python_VE> code . 6. D:\\ Code_Python_VE>代码。 This will start Visual Studio Code. 这将启动Visual Studio代码。 Make sure the command is (code .). 确保命令是(代码。)。
7. Create launch.jason with following content: 7.创建具有以下内容的launch.jason:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "python",
"request": "launch",
"name": "Python: Current File (Integrated Terminal 1)",
"program": "${file}"
},
{
"name": "Python: Current File (Integrated Terminal 2)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
},
]
}
(Please search how to go to Debug window and Add new Configuration in VS Code). (请搜索如何转到“调试”窗口并在VS Code中添加新配置)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.