【问题标题】:ImportError: No module named pkg_resources on installing matplotlibImportError:安装 matplotlib 时没有名为 pkg_resources 的模块
【发布时间】:2015-10-04 23:01:42
【问题描述】:

这是在 CentOs 6.6 上。我正在尝试建立一个科学的 python 环境。我想避开 Anaconda。尝试安装 matplotlib 时,我收到“ImportError:没有名为 pkg_resources 的模块”。完整的安装历史记录:

sudo yum install gcc-c++.x86_64
sudo yum install gcc
sudo yum install atlas atlas-devel lapack-devel blas-devel
sudo yum install python-devel
sudo pip install numpy
sudo pip install scipy
sudo pip install pandas
sudo pip install matplotlib

在最后一步,我收到消息

Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.

那我做

sudo pip install --upgrade distribute

安装distribute-0.7.3setuptools-18.0.1。那么:

sudo pip install matplotlib

导致:

File "/usr/bin/pip", line 5, in <module>
  from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

有什么想法吗?

更新

经过上述步骤,setuptoolspip 在此安装中被破坏。在 python shell 中,执行help() 后跟modules 不会列出setuptools。在文件系统中搜索setuptools 目录显示:

/usr/lib/python2.6/site-packages/setuptools-18.0.1.dist-info/

/usr/lib/python2.6/site-packages/ 中的setuptools.pth 文件包含指向不存在的./setuptools-0.6c11-py2.6.egg-info 的指针。

同时还有一个目录

/usr/share/doc/python-setuptools-0.6.10/

毕竟,pip 不再起作用。

【问题讨论】:

标签: python matplotlib centos installation pip


【解决方案1】:

@pavan 他们说 CentOS,所以 apt 不太可能帮助他们。

不过,他们可以这样做:

yum remove python-setuptools

yum install python-setuptools  

(我还需要重新安装pip:yum install python-pip)

这可能会解决问题。

【讨论】:

  • 这个项目已经很高兴地退役了,所以我再也无法访问那台 CentOS 机器了。下次需要这种方法时我会尝试,同时其他人可能能够检查重新安装 python-setuptools 是否可以解决问题。
【解决方案2】:

在支持 apt-get(Ubuntu 等)的操作系统上试试这个

sudo apt-get install python-pkg-resources python-setuptools --reinstall

【讨论】:

    【解决方案3】:

    尝试安装 python-pip(和依赖项):

    yum install python-pip
    

    这解决了我的问题(Centos 6.8 版)。

    【讨论】:

      猜你喜欢
      • 2015-12-22
      • 1970-01-01
      • 2015-01-21
      • 1970-01-01
      • 2017-01-09
      • 2016-02-26
      • 1970-01-01
      • 2016-10-26
      • 1970-01-01
      相关资源
      最近更新 更多