在OS X上使用PIP无法安装matplotlib

4
这是我第一次设置matplotlib。 我使用的是OS X Lion 10.7(构建11A511s,因此没有对OS X Lion初始版本进行更新)。 我正在使用virtualenv和pip进行安装。 我知道与libpng 1.5不兼容,所以我没有直接运行“pip install matplotlib”... 相反... 我尝试从虚拟环境内运行以下命令: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),但问题仍然存在。我也在Matplotlib的邮件列表中发布了帖子,但尚未收到回复。 - Blueplastic
2
不要试图在OS X Python中安装matplotlib。这是可行的,但非常困难。要么获取Enthought Python Distribution的副本,要么获取python.org上的Python 2.7版本(或者使用MacPorts也可以)。然后安装setuptools和pip,你就可以开始工作了。 - Chinmay Kanchi
好的,谢谢Chinmay。我会在今晚使用MacPorts进行最新的Python 2.7安装后重试。 - Blueplastic
我成功地在Mountain Lion上使用了您的方法安装了matplotlib。我使用Homebrew来管理事物,而不是MacPorts。我遵循了$brew doctor的建议,一旦警告得到解决,您的pip install -e git+https://github.com/matplotlib/matplotlib#egg=matplotlib-dev就可以工作了。 - Milktrader
Chinmay:你能把你的评论变成一个答案吗?我会投票支持它,我有一种感觉它会被采纳。 - sumek
我想提一下,现在(2013年)在Mountain Lion上使用pip安装matplotlib是可行的。 - SethMMorton
2个回答

0

三年后:

如果你是新手,安装matplotlib(或numpy或pandas或scipy)应该使用anaconda。这个建议适用于几乎任何平台。


0

嗯...除非你一心要使用pipvirtualenv来安装,否则可以试试这个:

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

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

cd matplotlib
python setup.py install

请参考this获取更多有关安装matplotlib的帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接