Visual Studio Code 忽略 settings.json 字段

当选择“运行代码”(默认热键)时,我似乎无法让我的settings.json文件影响 python 在 VSCode 中的调用方式,我的用户如下:Ctrl + Alt + Nsettings.json


{

    "python.pythonPath": "/usr/bin/python3",

    "editor.suggestSelection": "first",

    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",

    "python.jediEnabled": true,

    "editor.minimap.enabled": true,

    "editor.multiCursorModifier": "ctrlCmd",

    "workbench.tree.indent": 24,

    "workbench.startupEditor": "untitled",

    "workbench.settings.editor": "json",

    "workbench.settings.openDefaultKeybindings": false,

    "workbench.settings.openDefaultSettings": true,

    "workbench.settings.useSplitJSON": false,   

    "explorer.confirmDragAndDrop": false,

    "python.linting.enabled": true,

    "python.languageServer": "Jedi",

}

然而,当我运行我的 python 文件而不是调试它时,它显示:


[Running] python -u "path/to/file.py"

当我期待时(正如我设定的那样python.pythonPath)settings.json:


[Running] /usr/bin/python3 -u "path/to/file.py"

为什么我的settings.json文件密钥python.pythonPath对我的代码的调用方式没有影响?


python在其他重要原因中,当我的代码是用 python 3 编写时,我的python 代码甚至没有在我的机器上运行,因为调用 python 2。


VS代码版本:


Version: 1.47.3

Commit: 91899dcef7b8110878ea59626991a18c8a6a1b3e

Date: 2020-07-23T15:51:39.791Z (1 mo ago)

Electron: 7.3.2

Chrome: 78.0.3904.130

Node.js: 12.8.1

V8: 7.8.279.23-electron.0

OS: Linux x64 4.15.0-112-generic


偶然的你
浏览 246回答 1
1回答

胡子哥哥

从vscode-python-DeprecatePythonPath中,python.pythonPath正在从所有 3 个范围中删除设置 - User、workspace、workspace folder。工作区解释器的路径现在将存储在 VS Code 的持久存储中,而不是 settings.json 文件中。这就是为什么您的设置对代码执行路径没有影响。您可以使用 Python 更改存储在工作区设置中的值:选择解释器命令,或在用户settings.json中添加设置:"python.defaultInterpreterPath":
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python