【问题标题】:"Linter pylint is not installed" every time I start VS Code每次我启动 VS Code 时,“Linter pylint 没有安装”
【发布时间】:2021-01-08 13:18:42
【问题描述】:

每次我启动 VS Code 时,都会弹出一个带有红色叉号的小窗口,上面写着“Linter pylint 未安装”,其中包含 Install、Select Linter 或 Do not show again 三个选项。但是,当我点击Install 时,它会在/usr/bin/python 打开集成终端并告诉我“要求已经满足,跳过升级”。当我点击Select linter 时,我可以在列表末尾选择pylint。 which 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"
  ],```

【问题讨论】:

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


    【解决方案1】:

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

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

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

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

    【讨论】:

    • 感谢您的回答。我遵循了您的所有观点,我的 Python 版本与左下角(3.9.1)中显示的一致,pylint 安装在 /home//.local/lib/python3.9/site-包
    • @brij - 进展如何?现在打开VSCode,还会提示“Linter pylint is not installed”吗?
    • 不幸的是,是的,我仍然收到相同的消息,并且每次启动 VSCode 时都必须手动选择 pylint 作为我的 linter。
    【解决方案2】:

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

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

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

    【讨论】:

    • 感谢您的回答。不幸的是,它并没有解决问题,因为我试图在同一个环境中 pip install pylint 并且它说“要求已经满足”
    • 编辑了另外一个建议!
    • 问题是这是我工作的环境(/usr/bin/python)。我尝试在设置中删除该行,但没有任何改变,“pylint is not installed”照常弹出。
    • 天哪!悲惨。您可以尝试使用pip uninstall pylint 卸载/重新安装,并删除/重新添加 VS Code 的 Python 扩展。
    • 还要检查 pip 是否与 python 同步。例如,which pip 和 which python(在 mac/linux 上)以确保它们在同一个位置。
    猜你喜欢
    • 2018-10-22
    • 2021-07-17
    • 2022-10-02
    • 1970-01-01
    • 2020-10-16
    • 1970-01-01
    • 2017-09-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多