简体   繁体   English

如何为 python2.7 安装 pylint?

[英]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:我尝试在 ubuntu 18.04 中为 python2.7 安装 pylint,但它会引发以下错误:

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.我已经使用pip3为 python3.6 成功安装了 pylint。

So, how can I install the pylint for python2.7?那么,如何为 python2.7 安装 pylint?

pylint still maintains support for Python 2 until maybe next year or so. pylint 仍然保持对 Python 2 的支持,直到明年左右。 But you need to install 1.9.X instead of 2.X .但是您需要安装1.9.X而不是2.X It seems though that you already had pylint installed, once you uninstall it you should be able to get 1.9 instead.虽然您似乎已经安装了pylint ,但一旦您卸载它,您应该能够获得 1.9。

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.如今,安装 Python 库变得越来越困难,但如果您注意修复依赖项的版本,它仍然是可能的。

For PyLint, you should also fix the versions of configparser and isort which have been upgraded to Python 3.对于 PyLint,您还应该修复已升级到 Python 3 的configparserisort版本。

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.但是,您也可以对==使用严格约束,因为 Python 2.7 发布更新的可能性很小。

Here are the versions of the libraries installed to date (2020-07-12) by this command:以下是此命令迄今为止(2020-07-12)安装的库版本:

> 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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM