如何在python可视化代码扩展中预选(设置默认)python解释器?

2024-10-03 00:26:45 发布

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

小问题是,当我按下Ctrl+F5时,我希望代码立即运行;但我必须这样做

Select environment:

Python
Python Exprimental

一直这样。有没有一种方法可以在设置中设置默认的env,这样我就不必在每次运行时都进行选择?在


Tags: 方法代码envenvironmentf5selectctrlexprimental
3条回答

“文件”>;“首选项”>;“设置”>;“用户”选项卡>“扩展”>;“python”>;“python路径”

键入python路径,例如:c:\python35\python.exe

一旦您选择了一个解释器,它应该存储在设置.json在.vscode文件夹中。应该是这样的:

{
  "python.pythonPath": "C:\\Users\\Username\\AppData\\Local\\Programs\\Python\\Python36\\python.exe"
}

下次使用vscode打开此文件夹时,应该自动选择上次使用的python解释器。在

也许你没有用“打开文件夹”打开工作目录。然后vscode会尝试读取local.vscode文件夹(如果有的话),否则它会按照一定的路径顺序来选择解释器。希望有帮助。在

ctrl+shift+p启动命令托盘和

输入python解释器,您将得到一个选择解释器的选项

然后选择python解释器

Choosing an environment By default, the Python extension relies on the first Python interpreter it finds in the path, but it's easy to switch between environments.

To use a specific interpreter, select the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

相关问题 更多 >