在Windows 10中,如何配置Visual Studio代码以查找Python 3解释器?

2024-04-20 13:57:50 发布

您现在位置:Python中文网/ 问答频道 /正文

在Windows10中,如何配置VisualStudio代码来查找Python 3解释器

Visual Studio代码无法找到Python 3解释器

我已经添加了Python扩展,Python扩展位于 https://marketplace.visualstudio.com/items?itemName=donjayamanne.python

如何将settings.js更改为使用Python

即使将settings.js中的python.pythonPath更改为python.exe,它位于“C:\Users<;User>;\AppData\Local\Programs\Python\Python 36-32\p”‌如果我在命令调色板中选择Python: Select Workspace Interpreter,我会得到消息Please open a workspace to select the Python Interpreter。为什么会这样


Tags: 代码httpscomsettingsjsitems解释器studio
3条回答

在打开VS代码的当前目录中,转到.vscode/settings.json并修改json文件中的这一行:

 {
    "python.pythonPath": "path_to_your_python_bin", 
    # e.g., /home/myname/venv/bin/python3.7 or to a .exe file if you are on Windows
 }

马科斯

VSCode -> Preferences -> Settings -> scroll down to Python Configuration.

单击要使用的配置左侧的铅笔,然后单击复制设置

"python.pythonPath": "python3.6"

enter image description here

enter image description here

转到File/Preferences/Settings并查找Python Configuration。这是您手动更改配置的地方

您还可以从command palette中选择解释器。以下说明来自DonJayamanne's Github

Select the command Python: Select Workspace Interpreter from the command palette

Upon selecting the above command a list of discovered interpreters will be displayed in a quick pick list

Selecting an interpreter from this list will update the settings.json file automatically.

Command Pallet Screenshot

相关问题 更多 >