Python 错误:pkg#u resources.DistributionNotFound:The';backports.functools lru缓存';未找到分发,pylint需要分发

Python 错误:pkg#u resources.DistributionNotFound:The';backports.functools lru缓存';未找到分发,pylint需要分发,python,python-2.7,static-analysis,pylint,Python,Python 2.7,Static Analysis,Pylint,我正在尝试运行Pylint,但出现以下错误: pkg_resources.DistributionNotFound:找不到'backports.functools lru cache'分发,pylint需要该分发 我找到了下面的链接,但不确定如何处理这些文件或将它们放置在何处。 如何修复此问题?我遇到了同样的问题,安装了两个缺少的依赖项(pylint上的配置错误或未更新pip??) 只要做: 如果出现如下错误: raise DistributionNotFound(req) pkg_reso

我正在尝试运行Pylint,但出现以下错误:

pkg_resources.DistributionNotFound:找不到'backports.functools lru cache'分发,pylint需要该分发

我找到了下面的链接,但不确定如何处理这些文件或将它们放置在何处。


如何修复此问题?

我遇到了同样的问题,安装了两个缺少的依赖项(pylint上的配置错误或未更新pip??) 只要做:

如果出现如下错误:

raise DistributionNotFound(req)
pkg_resources.DistributionNotFound:configparser

只要做:

pip install configparser

我在CentOS 7上运行时遇到了这个问题

在CentOS上,backports模块打包为一个yum包(
python backports.x86_64

解决方案是使用选项创建virtualenv

首先验证是否安装了``python backports`包:

yum-list-installed | grep-python后台端口

然后创建/重新创建虚拟环境:

virtualenv-env系统站点包

这允许virtualenv的pylint在安装时查看backports模块

然后在虚拟环境中安装pylint:


env/bin/pip install pylint

据我所知,某些版本的RHEL/CentOS在其yum存储库中的backports.ssl-match-hostname包存在某种问题,当从PyPI更新其他backports包时,可能会导致问题。具体来说,在RHEL7.2环境中,我将问题再现如下:

> yum install python-pip  # indirectly installs backports.ssl-match-hostname
> pip2 install pylint     # indirectly installs backports.functools_lru_cache
> pip2 install --upgrade backports.ssl-match-hostname  # install latest package from pypi, which effectively corrupts backports.functools_lru_cache
> python2 -m pylint --version   # fails with missing import backports.functools_lru_cache
> yum install python-pip  # installs backports.ssl-match-hostname as a transitive dependency
> pip2 freeze > temp_reqs.txt  # take a snapshot of the installed packages and versions
> pip2 uninstall backports.ssl-match-hostname  # remove the yum installed package
> pip2 install -r temp_reqs.txt  # reinstall the same version of the backports package, but install from PyPI
我发现避免这种情况的唯一方法是用PyPI中的等效软件包替换yum安装的软件包。这可以通过以下方式完成:

> yum install python-pip  # indirectly installs backports.ssl-match-hostname
> pip2 install pylint     # indirectly installs backports.functools_lru_cache
> pip2 install --upgrade backports.ssl-match-hostname  # install latest package from pypi, which effectively corrupts backports.functools_lru_cache
> python2 -m pylint --version   # fails with missing import backports.functools_lru_cache
> yum install python-pip  # installs backports.ssl-match-hostname as a transitive dependency
> pip2 freeze > temp_reqs.txt  # take a snapshot of the installed packages and versions
> pip2 uninstall backports.ssl-match-hostname  # remove the yum installed package
> pip2 install -r temp_reqs.txt  # reinstall the same version of the backports package, but install from PyPI
现在,已安装的软件包应能按预期工作。执行以下测试用例可确认这一点:

> pip2 install pylint
> pip2 install --upgrade backports.ssl-match-hostname  # previously caused corruption of backports.functools_lru_cache used by pylint
> python2 -m pylint --version  # now works correctly

希望这能帮助其他人解决这个问题。

它是哪个版本的pylint?你是如何安装pylint的?我使用了pip install-pylint命令我也在OSX下运行了这个命令,这是值得的。