如何解决依赖地狱以安装matplotlib?

时间:2016-05-20 10:58:41

标签: python matplotlib dependencies pip

我想通过matplotlib安装pip。但是,我遇到了循环问题,在某些时候我陷入困境。在终端中运行pip会产生:

Traceback (most recent call last):
  File "/usr/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 3080, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3066, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3093, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 651, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 952, in require
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 839, in resolve
pkg_resources.DistributionNotFound: The 'pip==1.5.4' distribution was not found and is required by the application

我尝试使用easy_install解决此问题,但它产生了以下错误消息:

Traceback (most recent call last):
  File "/usr/bin/easy_install", line 5, in <module>
    from pkg_resources import load_entry_point
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3080, in <module>
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3066, in _call_aside
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3093, in _initialize_master_working_set
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 653, in _build_master
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 666, in _build_from_requirements
  File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 839, in resolve
pkg_resources.DistributionNotFound: The 'setuptools==3.3' distribution was not found and is required by the application

正在运行sudo apt-get install python-setuptools说我已经拥有最新版本。

我的操作系统是Ubuntu 14.04。我已经尝试了许多不同的方法来解决这个问题,并可能最终造成进一步的伤害。我不记得我做过的一切以及我在这个阶段的结局,所以很遗憾无法提供进一步的信息。

我的目标是最终安装matplotlib并保持所有python相关库的稳定状态。任何解决方案都可行,所以我不介意重新安装一切或任何能解决问题的方法。

更新

正在运行sudo apt-get build-dep python-matplotlib生成

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Picking 'matplotlib' as source package instead of 'python-matplotlib'
E: Unable to find a source package for matplotlib

sudo apt-get install python-matplotlib生成

Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-matplotlib is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

但是,matplotlib仍未找到python

1 个答案:

答案 0 :(得分:0)

尝试:

sudo apt-get build-dep python-matplotlib

这应该通过Ubuntu软件包管理系统安装matplotlib需要的依赖项(因为很多这些依赖项与pip一起安装并不容易),使您能够:

 pip install matplotlib

来源:Matplotlib documentation

我在Ubuntu 14.04和Kubuntu 15.10上都使用了这个过程来安装最新的,稳定的matplotlib(在虚拟环境中,但这应该没什么区别)。