【问题标题】:Visual Studio Code ignores settings.json field: python.pythonPathVisual Studio Code 忽略 settings.json 字段:python.pythonPath
【发布时间】:2020-12-11 23:34:59
【问题描述】:

在选择“运行代码”(默认热键Ctrl + Alt + N)时,我似乎无法让我的settings.json文件影响在VSCode中如何调用python,我的用户settings.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"

当我期待时(正如我在 settings.json 中设置的 python.pythonPath):

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

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

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

VSCode 版本:

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

【问题讨论】:

    标签: python python-3.x linux visual-studio-code


    【解决方案1】:

    vscode-python-DeprecatePythonPathpython.pythonPath 设置从所有 3 个范围 - 用户工作区工作区文件夹中删除。工作区解释器的路径现在将存储在 VS Code 的 persistent storage 中,而不是 settings.json 文件中。这就是您的设置对代码执行路径没有影响的原因。您可以使用 Python: Select Interpreter 命令更改存储在工作区设置中的值,或在 User settings.json 中添加设置:

    "python.defaultInterpreterPath":
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-18
      • 2018-12-11
      • 2017-05-21
      • 2015-07-10
      • 1970-01-01
      • 2021-07-30
      • 2020-02-06
      • 1970-01-01
      相关资源
      最近更新 更多