在Windows 10中如何设置Visual Studio代码以查找Python 3解释器。在Windows 10中,Visual Studio代码未找到Python 3解释器。我添加了可以在 https://marketplace.visualstudio.com/items?itemName=donjayamanne.python找到的Python扩展。如何编辑settings.js以使用Python?即使settings.js中的python.pythonPath更改为导致python.exe,在Windows 10中为“C:\ Users \\ AppData \ Local \ Programs \ Python” \ Python36-32 \ python.exe”。 VS代码,当在命令调色板中输入Python: Select Workspace Interpreter
时,会显示消息“Please open a workspace to select the Python Interpreter
”。为什么?
去File/Preferences/Settings
找到Python Configuration
。您可以在此处手动更改配置。
您也可以从command palette
中选择翻译。以下说明来自DonJayamanne's Github。
从
Python: Select Workspace Interpreter
中选择命令command palette选择上述命令后,已发现的解释器列表将显示在快速选择列表中
从此列表中选择解释器将自动更新
settings.json
文件。
我也在Windows 10上的Visual Studio Code中使用这个Python extension.Python安装在C:\ Python27 \和C:\ Python36 \中,两个文件夹都添加到Windows PATH variable使用此设置VS Code应该能够找到Python翻译。至少在我的环境中它运作良好。
但VS采用了它能找到的第一个解释器,在我的例子中是3.6版本。当我需要一个项目的2.7时,我必须明确告诉VS Code在配置文件中使用那个settings.json
在VS Code中按Ctrl键,然后在右侧窗口中添加:
{
"python.pythonPath": "c:/python27/python.exe"
}
或者PC上Python解释器的路径。
这也在Wiki under Manual Configuration中描述。现在,使用此设置,使用了Python 2.7。
一些不起作用的是自动检测Python版本,因此我也无法使用Select an Interpreter
命令选择我需要的版本。
我也有这个问题。我做了什么@jps说,它仍然没有工作,但后来我改变了我的环境设置顺序,以便Python36在Python27之前,它工作。
在我的情况下,我已经看到您正在使用的实际工作区覆盖文件/首选项/设置(Windows)或代码/首选项/设置(Mac)。
解决方案是手动编辑工作区文件(通常在主目录中)或创建新工作区并重新添加代码目录。