Riko
Riko

Reputation: 276

How can I install the pylint for python2.7?

I try to install the pylint for the python2.7 which in ubuntu 18.04, but it raises an error with this words:

pip install pylint                                  
Collecting pylint
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/04/1f/1d3929051b45c3e4015178c5fe5bbee735fb4e362e0fc4f0fbf3f68647ad/pylint-2.1.1.tar.gz
pylint requires Python '>=3.4.*' but the running Python is 2.7.15

I have been used the pip3 installed the pylint successfully for python3.6.

So, how can I install the pylint for python2.7?

Upvotes: 6

Views: 12764

Answers (2)

Laurent LAPORTE
Laurent LAPORTE

Reputation: 22952

Nowadays, it is becoming more and more difficult to install Python libraries, but it is still possible if you take care to fix the dependencies' versions.

For PyLint, you should also fix the versions of configparser and isort which have been upgraded to Python 3.

So, the command to run is :

pip install "pylint<2" "configparser~=4.0.2" "isort~=4.3.21" "lazy-object-proxy~=1.6.0"

Note that here, with the ~=, I used version constraints that would allow to install the latest bug fix of each library. But, you can also use a strict constraint with == as there is little chance that an update will be released for Python 2.7.

Here are the versions of the libraries installed to date (2020-07-12) by this command:

> pip freeze
astroid==1.6.6
backports.functools-lru-cache==1.6.4
configparser==4.0.2
enum34==1.1.10
futures==3.3.0
isort==4.3.21
lazy-object-proxy==1.6.0
mccabe==0.6.1
pylint==1.9.5
singledispatch==3.6.2
six==1.16.0
wrapt==1.12.1

Upvotes: 3

PCManticore
PCManticore

Reputation: 1064

pylint still maintains support for Python 2 until maybe next year or so. But you need to install 1.9.X instead of 2.X. It seems though that you already had pylint installed, once you uninstall it you should be able to get 1.9 instead.

Upvotes: 7

Related Questions