【问题标题】:How to resolve the dependency hell in order to install matplotlib?如何解决依赖地狱以安装 matplotlib?
【发布时间】:2020-02-23 21:48:37
【问题描述】:

我想通过pip 安装matplotlib。但是,我遇到了循环问题,并且在某些时候我被卡住了。在终端中运行 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.

但是,在python 中仍然找不到matplotlib

【问题讨论】:

  • 您考虑过与virtualenv.合作吗?
  • 我不确定它是否会让我的生活更轻松并且更像是一种解决方法。我不知道它是如何工作的,但我从事的项目主要是一个C 项目,我们使用python 来处理一些花哨的东西,所以我希望能得到更一般的修复。
  • virtualenv 也可以用作一般修复程序。如果您必须分发软件而无需人们安装所有必需的库,并且在不同的机器上运行程序时,它会派上用场。设置和使用相当简单:virtualenv.pypa.io/en/stable/userguide.html
  • 我曾经不得不让脚本在没有 sudo 访问权限的机器上运行,用 virtualenv..my 两美分做到这一点

标签: python matplotlib dependencies pip


【解决方案1】:

试试:

sudo apt-get build-dep python-matplotlib

这应该通过 Ubuntu 包管理系统安装 matplotlib 所需的依赖项(因为使用 pip 安装许多这些依赖项并非易事),使您能够:

 pip install matplotlib

来源:Matplotlib documentation

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

【讨论】:

  • 不幸的是,它并没有解决问题。查看我的编辑。
  • 您确定使用正确的 Python 安装来查找 matplotlib?根据sudo apt-get install python-matplotlib命令应该安装它,但也许你使用的不是系统Python,而是一些自定义安装,找不到系统Python的包。试试which python(对于系统 Python 应该是 /usr/bin/python)。
  • 是的,我也这么认为。 which python 确实返回了/usr/bin/python,所以我不知道可能出了什么问题。
  • 打开系统 Python 控制台 (/usr/bin/python) 并尝试help('modules')。如果尽管被告知已安装 matplotlib 并且尽管使用了系统 Python,但您仍然看不到 matplotlib,那我就没有主意了。
  • 它没有。我问了另一个问题来解决这个问题:stackoverflow.com/questions/37348123/…
猜你喜欢
  • 2015-12-20
  • 1970-01-01
  • 1970-01-01
  • 2016-02-19
  • 1970-01-01
  • 2016-08-16
  • 1970-01-01
  • 1970-01-01
  • 2017-07-20
相关资源
最近更新 更多