每次启动 VS Code 时都会出现“未安装 Linter pylint”

时间:2021-01-08 13:18:42

标签: python visual-studio-code vscode-settings pylint

每次我启动 VS Code 时,都会弹出一个带有红十字的小窗口,提示“未安装 Linter pylint”,其中包含 InstallSelect LinterDo not show again 三个选项。但是,当我点击 Install 时,它会在 /usr/bin/python 处打开集成终端并告诉我“要求已经满足,跳过升级”。当我点击 Select linter 时,我可以选择列表末尾的 pylintwhich pylint 返回“找不到 pylint”。这让我发疯。它最近开始以这种方式行为不端,但我不确定是什么原因造成的。 我已经尝试了此线程中的所有答案 Linter pylint is not installed 和此线程 Getting error message "Linter pylint is not installed" 但没有任何变化。 pip3 install pylint 返回“要求已经满足”。我需要一些帮助。

这些是我的 linting 设置:

  "python.pythonPath": "/usr/bin/python",
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": true,
  "python.linting.pylintPath": "python -m pylint",
  "python.linting.pylintArgs": [
    "--extension-pkg-whitelist=pygame",
    "--errors-only"
  ],```

2 个答案:

答案 0 :(得分:0)

在 VS Code 窗口的左下角,它会告诉您编辑器当前使用哪个 Python 环境来评估/运行您的代码。 (这只会在您在编辑器中打开 Python 文件后出现。)您可以点击它进行更改。

您需要确保 pylint 安装在您选择的相同环境中。这可能是问题所在!

编辑:在我的 settings.json 中,我没有 "python.pythonPath": "/usr/bin/python"。也许这会导致问题,如果它与您选择的 Python 环境不同?

答案 1 :(得分:0)

请检查已安装的模块“Pylint”是否在当前选择的Python环境中安装成功:

  1. 请使用命令“python --version”查看 VSCode 终端当前所在的 Python 环境:

    enter image description here

    如果结果与VSCode左下角显示的不一致,请使用快捷键Ctrl+Shift+`打开一个新的VSCode终端,会自动进入选中的终端。

2.我们可以使用“pip show pylint”来查看“Pylint”的安装位置:

enter image description here