I'm interested in running a checker over my Python 3 code to point out possible flaws. PyChecker does not work with Python 3. I tried to pip-install Pylint, but this fails. The error message does not help me (see paste).
Pylint's Readme states that:
Pylint should be compatible with any python >= 2.2.
However, the page somehow feels outdated.
Is pylint compatible with Python 3?
If yes, how can I install it?
If no, are there alternatives I should look into?
Yes, pylint versions > 0.23.0 do support Py3K.
Your issue seems to be described in http://www.logilab.org/82417 (also Getting started with Pylint for Jython (jython2.5.1))
The cached ticket page recommends running:
$ NO_SETUPTOOLS=1 python3.2 setup.py install --no-compile
$ easy_install-3.2 logilab-common
$ easy_install-3.2 logilab-astng
# You can probably use pip instead of easy_install...
I've managed to get pylint running in Python3 on Linux (Ubuntu12.04, though I don't think the version matters in the following) after a bit of a struggle. I'm not exactly sure what I did wrong along the line, but various files were in the wrong place or had the wrong access mode and all normal procedures failed. [Attempts to install pylint via apt-get and pip certainly contributed to the mess.] I think the following sequence was what got everything unscrewed again. In case it helps someone else (no guarantees) here's what I just did:
- Make sure that /usr/bin/python is a symbolic link to
/usr/bin/python3.2 not /usr/bin/python2.7
[edit I subsequently had trouble with various Python2 scripts failing as a result of this, so you may want to reset it to python2 after getting pylint installed.]
- sudo vi /usr/local/lib/python3.2/dist-packages/easy-install.pth and delete any references to pylint and logilab eggs. [There shouldn't be any if you've just started.]
- Download pylint from http://pypi.python.org/pypi/pylint/0.26.0. Unzip etc.
- cd into the unzipped pylint directory and type the command 'sudo python3 setup.py install'
At that stage the command 'pylint' worked but only for the superuser. Some files weren't world readable. The following two command sorted them out:
- sudo chmod a+rx /usr/local/bin/pylint
- sudo chmod a+rX -R /usr/local/lib/python3.2
Good luck!
EDIT: I just went through the install process on another Linux box in a clean state, and apart from having also to install the two dependencies (logilab-common and logilab-astng) in exactly the same way as pylint above, it all went well. So it looks as though the problems arose through installing a version for Python 2 first and possibly through the use of pip.
For Ubuntu 14.04:
sudo aptitude install python3-pip
sudo pip3 install pylint
/usr/local/bin/pylint your_file.py