Setting up Pylint with PyDev

青春壹個敷衍的年華 提交于 2019-11-30 11:55:33

问题


I have installed pylint via easy_install. I can run pylint <filename> with success. But pydev refuses to use it.

  • I checked "use pylint"
  • I configured correct path
  • I updated my python interpreter in eclipse to have pylit in pythonpath
  • I use Eclipse Galileo
  • I have build automatically checked
  • I tried cleaning whole project and no errors

What am I doing wrong?


回答1:


I'm guessing you may need to mark the folder that contains your code as a source folder. You can do this under project properties.

  • Project->Properties->PyDev-PYTHONPATH
  • add relevant folders to the list of sources.



回答2:


I've noticed that Pydev won't run Pylint on files with dashes (hyphens) the the filename; according to the Pydev devs, '-' is not a valid Python module name character, and it doesn't look like they intend to fix it:

http://sourceforge.net/tracker/index.php?func=detail&aid=1915426&group_id=85796&atid=577329

http://sourceforge.net/tracker/index.php?func=detail&aid=2888890&group_id=85796&atid=577332

As if nobody writes scripts in Python... Grumble grumble...




回答3:


To provide an alternative solution, pylint can be used as an External Tool in Eclipse. This requires having previously installed the pylint package for a Python installation.

Remember to first have a pylintrc file somewhere where pylint can find it, failing which a "No config file found" error is printed. Typically I would touch pylintrc inside the project directory, and keep the file in version control. For reference, see pylint command-line options.

In Eclipse, select Run, External Tools, External Tools Configurations.... Click the toolbar button to create a New launch configuration. Configure as below or as desired:

  • Name: pylint
  • Location: ${system_path:pylint}
  • Working Directory: ${project_loc}
  • Arguments: --reports=n "${resource_loc}"

Remember to click inside an open file to switch focus to it before running the above external tool for it. Failing this, an error can occur.

The output of the external tool will by default be printed to the console.


Related: Setting up pep8 as an External Tool in Eclipse



来源:https://stackoverflow.com/questions/2538244/setting-up-pylint-with-pydev

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!