简体   繁体   English

在Visual Studio Code中使用pylint

[英]Using pylint with Visual Studio Code

I downloaded Visual Studio Code the other day and I decided to use it with pylint. 前几天,我下载了Visual Studio Code,因此决定将其与pylint一起使用。

For some odd reason I couldn't set the python interpreter to python 3 from the palette (Shift + Ctrl + P) but I set the path to it from the settings and it seems to have done the job. 出于某种奇怪的原因,我无法将python解释器从面板(Shift + Ctrl + P)设置为python 3,但是我从设置中设置了它的路径,这似乎已经完成了。 However, pylint underlines almost everything. 但是,pylint强调了几乎所有内容。 All of my imports are underlined with the error message: 我的所有导入都带有错误消息加下划线:

[pylint] E0401:Unable to import 'my.import' [pylint] E0401:无法导入“ my.import”

I read a couple of threads on this topic and the main suggestions are to set the correct python path and path to pylint, which I have done with 0 success. 我阅读了有关该主题的几个主题,主要建议是设置正确的python路径和pylint的路径,我已成功完成0。 I tried removing it pip3 remove pylint and reinstalling it, however, it still did not fix my issue. 我尝试将其pip3 remove pylint并重新安装,但是,它仍然无法解决我的问题。

You may try setting "python.linting.pylintPath" key separately. 您可以尝试单独设置"python.linting.pylintPath"键。

In settings.json you can set like this; settings.json您可以这样设置:

"python.linting.pylintPath": "/home/user/.local/bin/pylint"

user will be your user name of course 用户将是您的用户名

if you use linux and want to find exact location of pylint you can run which pylint command in terminal 如果您使用linux并希望找到pylint的确切位置,则可以在终端中运行which pylint命令

要解决此问题,可以在preferences-> settings python.pythonPath设置python安装的路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM