My understanding is that the latest release of Pylint (1.0.0 at the time of this writing) has support for Python 3, but I can't get it to work on 64-bit Ubuntu 13.04 with Python 3.3.

I followed the installation instructions on the PyPi site, and Pylint 1.0.0 seems to be installed successfully (pylint --version returns pylint 1.0.0), and works with Python 2.7 code, but it reports a syntax error when it sees nonlocal statements and such.

What gives? Are there special installation instructions for Pylint on Ubuntu?


Python 2 and 3 are separate beasts. If you install a script into the site-packages of one version, you are not installing it into the other.

I'd install it through pip, but you'll need the right version of pip.

sudo apt-get install python3-pip
sudo pip-3.3 install pylint

This will replace your 2.7 version. We can confirm this by checking less $(which pylint):

# EASY-INSTALL-ENTRY-SCRIPT: 'pylint==1.0.0','console_scripts','pylint'
__requires__ = 'pylint==1.0.0'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
        load_entry_point('pylint==1.0.0', 'console_scripts', 'pylint')()
  • Great. That works. I'll note, however, that those commands did not replace the 2.7 version on my machine. I had to remove it from the 2.7 dist-packages, and then rerun the commands. Sep 3 '13 at 17:12
  • 3
    @Oli so if I install pylint for python 3 then the default python 2 version doesn't work?
    – sayth
    Sep 8 '13 at 3:07
  • 7
    I found out that with newer versions (as of Python 3.5 etc. Nov 2016) there is also a pylint3 which you can install with: sudo apt install pylint3. Nov 27 '16 at 2:32

@sayth 's comment to the accepted answer was what drew me here -- I write both python 2 and python 3 scripts, and I want to be able to check either against the correct ruleset. installing pylint using pip3 install pylint writes a short script to /usr/local/bin which invokes the python3 interpreter, and seems, therefore to assume all files to be checked are python 3 scripts.

to work around this, I now have the following files:


# EASY-INSTALL-ENTRY-SCRIPT: 'pylint','console_scripts','pylint'
__requires__ = 'pylint'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
        load_entry_point('pylint', 'console_scripts', 'pylint')()

and ~/bin/pylint3:

# EASY-INSTALL-ENTRY-SCRIPT: 'pylint','console_scripts','pylint'
__requires__ = 'pylint'
import sys
from pkg_resources import load_entry_point

if __name__ == '__main__':
        load_entry_point('pylint', 'console_scripts', 'pylint')()

and then, because I like to use pylint directly from Geany's "Build Commands" menu, and I can't specify different commands for python 2 and python 3 scripts, i also have ~/bin/pylint:

if [[ $(head -n 1 "${@: -1}") == *python3* ]]
    # python3 file
    pylint3 "$@"
    pylint2 "$@"

which dispatches the correct version by sniffing the shebang.

Not perfect, certainly, but functional and, perhaps, useful for others.


The pylint ecosystem has changed since (after this question was asked), and there is now a separate pylint for python3. It can be installed with:

sudo apt install pylint3

Worked for me on Ubuntu 16.04.2 LTS

  • 1
    this works for me as well. Installed pylint for python3, and still keep pylint for python 2.
    – zhihong
    Sep 12 '17 at 15:24
  • This answer is the correct one for system-wide installation.
    – jII
    Apr 30 '19 at 18:12
  • Note that if you use a system-wide installation but then want to analyse a project inside a virtualenv, it won't find your imports. See for instance github.com/Microsoft/vscode-python/issues/1185 "This is a common error that most people come across. You have not installed pylint in the same environment that contains your python packages." Apr 8 '20 at 5:54

As another method for running pylint on both Python 2 and 3, note that you can use Python's -m switch to run a module installed on the system in the current version of Python, so you can do

$ python2 -m pylint
$ python3 -m pylint

to explicitly select which one you want. You could make these into aliases or shell scripts if you wanted.


The root of the problem is that pylint should come with entry point console scripts for /usr/local/bin/pylint2 and /usr/local/bin/pylint3. This should be considered a bug.

The following does not work; it still runs pylint2:

python3 -m pylint p3file.py

The following is what I have been using successfully:

python2 /usr/local/bin/pylint p2file.py
python3 /usr/local/bin/pylint p3file.py

This is in response to simons fine answer. I just thought about it in a different way and thought it could be useful for those seeking solutions for multiple versions of python/pylint.

Installing pylint for 3.x and keeping 2.7 default or vise versa is easily done using virtualenv.

Create your virtual environment. in your env while activated run

    pip install pylint

here you can then figure out where your env has put your python and pylint by

    which pylint

and then

    which python

Then it's just a matter of setting up your ide to use that linting path and/or python path. I know it works with Sublime3 so Ill use that in the example below.

in Sublime in the top header menu select Preferences > Package Settings > Pylinter > Settings - User.

It's just a json object. Set the

    "python_bin": "python",
    // to the python path found earlier by 'which python'
    "python_bin": "/home/$USER/Desktop/python/awesomeSauce/bin/python",
    // dont for get the coma if it is the last element.
    // We also change the pylint_path from
    "pylint_path": null,
    // to
    "pylint_path": "/home/$USER/Desktop/python/awesomeSauce/bin/pylint",
    // sorry I cant make the formatting look any better.

Save the file. I also make a copy of the file and keep it in that venv directory so I can easily switch by copying and pasting this config when I need this linter. When I don't I just reset the Pylinter.sublime-settings back to the default for user and that seems to be the easiest way I have found. Sorry I dont know the windows commands or I would have put them in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.