未安装 linter pylint vscode

linter pylint is not installed vscode

我知道这个问题有多个版本,我已经尝试了发布在这些线程上的解决方案,但它们似乎没有帮助:(

我在 Ubuntu VM 中安装了 VS Code。我似乎无法让 python linter 工作。即我收到一条消息说

Linter pylint is not installed 

我很确定 VM 上安装了 pylint,因为当我 运行 which pylint 我有一个有效的输出。

这里分别是 which pythonwhich pylint 的输出

/usr/bin/python
/home/rakshak/.local/bin/pylint

我在 VS Code 的用户设置和工作区设置中有以下内容

// Place your settings in this file to overwrite the default settings
{
       "python.linting.pylintEnabled": true,
       "python.linting.pylintPath": "/home/rakshak/.local/bin/pylint",
       "python.pythonPath": "/usr/bin/python"
}

您检查过您安装的 pylint 是哪个 python 版本吗? 如果你使用过 python 3.6 那么设置必须是这样的:

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

原来这只是一个权限问题!

当我收到 pylint not installed 消息时,我看到了一个按钮 "Install pylint" 这会运行

sudo pip install pylint

这将我的 .local/lib/ 的所有者更改为 root,并使 vscode 无法访问它。

ls -ld ~/.local/lib/ 的输出是

drwx------ 3 root root 4096 Sep 24 10:49 /home/userName/.local/lib/

与我的组和用户一起运行 chown 解决了这个问题。

sudo chown -R group:user ~/.local

现在 ls -ld ~/.local/lib/ 的输出显示为

drwx------ 3 userGroup userName 4096 Sep 24 10:49 /home/rakshak/.local/lib/