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?
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.
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...
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.
来源:https://stackoverflow.com/questions/2538244/setting-up-pylint-with-pydev