无法使用 pip 安装包 pkg_ressources.DistributionNotFound

无法使用 pip 安装包 pkg_ressources.DistributionNotFound

我升级到了 Ubuntu 16.04,pip 现在似乎坏了。我无法用它安装任何软件包,甚至运行诸如 pip -version 或 pip install -U pip 之类的命令,也会出现相同的错误消息:

    Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2927, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2913, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 637, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 650, in _build_from_requirements
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 829, in resolve
pkg_resources.DistributionNotFound: The 'pip==1.5.4' distribution was not found and is required by the application

有解决方案吗?我该如何修复它?

答案1

我让 pip 再次像这样工作。我试过:

sudo apt-get purge python-pip
sudo rm /usr/bin/pip /usr/local/bin/pip
sudo apt-get install python-pip

但后来我收到一条错误消息,因此我使用以下命令创建了一个从到 的usr/local/bin/pip not found符号链接:/usr/local/bin/pip/usr/bin/pip

sudo ln -s /usr/bin/pip /usr/local/bin/pip

现在 pip 可以工作了。

答案2

就我而言,我之所以出现此错误,是因为 pip 包被安装了多次

我修复了此错误,通过删除修复,rm /usr/local/bin/pippip发现了~/.local/bin/

相关内容