Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 480
Riko Avatar asked Aug 08 '18 12:08

Riko


People also ask

How do I install a specific version of Pylint?

If you want to install a specific version, run the following command with the version you wish to install. For example, to install version 2.7. 1, run the following: pip install --force-reinstall pylint==2.7.

Is pip for python2?

pip installation To use pip, first install a custom version of Python 2. pip is then installed with it. You can then use the pip command to create a virtualenv and install modules.


2 Answers

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.

like image 181
PCManticore Avatar answered Oct 06 '22 12:10

PCManticore


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
like image 35
Laurent LAPORTE Avatar answered Oct 06 '22 11:10

Laurent LAPORTE