vscode pylint linter 的路径无效

vscode Path to the pylint linter is invalid

我在 Windows 7 上使用虚拟环境(路径 /c/Users/xxxxxxx/Envs/tutorial)使用 VS Code 运行。 [即将Windows10]

我一直在屏幕左下角弹出以下错误消息:

Path to the pylint linter is invalid
(/c/Users/xxxxxxx/Envs/tutorial/Scripts/pylint)
Source: Python (Extension)

我使用 ctrl+shift+p > Python:select interpreter 选择了 Python 解释器。 如果我打开一个终端并且 运行:

$ "${PWD}/Scripts/pylint.exe" --version

输出为:

pylint 2.3.1
astroid 2.2.5
Python 3.7.4 (tags/v3.7.4:e09359112e, Jul  8 2019, 20:34:20) [MSC v.1916 64 bit (AMD64)]
(tutorial)

看起来不错。

我应该在 settings.json 中设置什么来为这个虚拟环境设置 linter 的路径吗?

您似乎已将 Pylint 安装到您正在使用的虚拟环境中。如果这是真的,那么您不需要指定 "python.linting.pylintPath",而是可以依赖 python -m pylint 工作。

尝试重新安装“Pylance”和“Python”扩展并重新加载或重新启动您的 VSCode. 希望这能解决您的问题。