【问题标题】:Can't install matplotlib on OS X with PIP无法使用 PIP 在 OS X 上安装 matplotlib
【发布时间】:2011-12-28 09:32:55
【问题描述】:

这是我第一次设置 matplotlib。
我使用的是 OS X Lion 10.7(构建 11A511s,因此没有对 OS X Lion 的初始版本进行更新)。
我正在使用 virtualenv 和 pip 进行安装。
我知道与 libpng 1.5 不兼容,所以我不只是运行“pip install matplotlib”...而是...
我尝试从 virtualenv 内部运行它:

pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev

看起来它开始安装,但随后出现此错误:

/Users/myusername/.virtualenvs/nltk/lib/python2.7/site-packages/numpy/core/include/numpy/
__multiarray_api.h:1532: warning: ‘int _import_array()’ defined but not used

lipo: can't open input file: /var/folders/wy/s1jr354d4xx7dk0lpdpbpsbc0000gn/T/
/ccfNUhyq.out (No such file or directory)

error: command 'llvm-gcc-4.2' failed with exit status 1

----------------------------------------
Command /Users/sameerfx/.virtualenvs/nltk/bin/python -c "import setuptools; __file__=
'/Users/sameerfx/.virtualenvs/nltk/src/matplotlib/setup.py'; exec(compile(open(__file__
).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps failed with error code 1
Storing complete log in /Users/sameerfx/.pip/pip.log

【问题讨论】:

  • 更新:我已将 OS X 上传到 10.7.2(Build 11C74),但问题仍然存在。我也发到了 Matplotlin 的邮件列表,但还没有回复。
  • 忘记使用 OS X Python 安装 matplotlib。可以做到,但非常痛苦。要么让自己获得一份 Enthought Python Distribution 的副本,要么从 python.org 获得一份 Python 2.7 的副本(或者使用 MacPorts,一切都很好)。然后安装 setuptools 和 pip 就可以了。
  • 酷,谢谢钦梅。今晚我将在使用 MacPorts 安装最新的 Python 2.7 后重试。
  • 我能够在 Mountain Lion 上使用您的方法安装 matplotlib。我正在使用 Homebrew 而不是 MacPorts 来管理事物。我遵循了$brew doctor 的建议,一旦警告得到解决,你的pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev 就起作用了。
  • Chinmay:你能把你的评论作为答案吗?我会投票赞成,我觉得它会被接受

标签: python matplotlib virtualenv pip


【解决方案1】:

三年后:

如果您不熟悉该过程,则应使用 anaconda 安装 matplotlib(或 numpy、pandas 或 scipy)。这个建议也适用于几乎所有平台。

【讨论】:

    【解决方案2】:

    嗯...除非您一心想使用pipvirtualenv 进行安装,请尝试以下操作:

    git clone git://github.com/matplotlib/matplotlib.git
    

    然后像往常一样构建和安装:

    cd matplotlib
    python setup.py install
    

    有关更多matplotlib 安装帮助,请参阅this

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 2011-05-04
      • 2015-07-09
      • 2020-01-10
      • 2013-09-29
      • 2014-03-23
      • 2012-03-29
      相关资源
      最近更新 更多