Python Pylint/Pydev Code Checking in Eclipse

Pylint is a good python code checking tool.  Pydev is a good plugin for Eclipse for editing and running python programs.  Much of this info is taken from Ryan Fraser's page .  Wolfgang has an alternative description for installing pylint in the Komodo python IDE here

Install python:

Install Pylint into python:

  • Download pylint compressed directories:
  • Unzip these tar.gz files on Windows with Winzip: the older 10.0 version which seems to work well is here
    • I just unzipped each to its own directory within my python install directory
    • Go into each of these directories and run the script which will also create a new Scripts directory in your python directory:
      • cd logilab-common-0.51.1
      • run python install
      • cd ..\logilab-astng-0.20.2
      • run python install
      • cd ..\pylint-0.21.2
      • run python install

Set PYTHONPATH and path environment variables

  • Append the Python installation directory and Lib directory to the PYTHONPATH environmental variable.
    • For example: D:\Python26;D:\Python26\Lib
  • Make sure your Python installation and Scripts directory is included in the path environmental variable.
    • For example: D:\Python26\Scripts;D:\Python26\

Install Pydev into Eclipse

  • Install the plugin through the Eclipse menu Help -> Eclipse Marketplace
    • Look for Pydev and click the Install button
    • Only checkmark the Pydev for installation: the Django editor has errors when trying to install and the default python editor works fine
  • Go to Window -> preferences -> Pydev -> Interpreter - Python
    • Click the Auto Config to find python on your system or click New and set the path to python.
  • Go to Window -> preferences -> Pydev -> Pylint
    • Enter the location of pylint ( eg. C:\python26\pylint-0.21.2\
    • Also checkmark "Use Pylint?"
    • You need to enable warnings if you want to see all possible code issues
    • You can fill in the pylint arguments text area with something like --disable-msg=c0301 to filter out warnings for too long lines, but this appears to actually filter out all ID type warnings
  • Create a new Pydev project in Eclipse or make sure your existing python project is checking your python script source files:
    • Go to Project->Properties->PyDev-PYTHONPATH
      • Add source folders to the list of sources (directories containing the python code you want checked), otherwise PyLint will NOT start
      • Pylint should run whenever the source is changed and built, but you can go to the menu Project -> Clean... to force the python script to be built and code checked by Pylint