在Mac OSX Mountain Lion上安装matplotlib

5

我想安装matplotlib,但是遇到了很多问题。无论是使用pip安装matplotlib还是尝试从源代码构建都会遇到一个常见的错误:

BUILDING MATPLOTLIB

        matplotlib: 1.1.1

            python: 2.7.2 (default, Jun 20 2012, 16:23:33)  [GCC 4.2.1

                    Compatible Apple Clang 4.0

                    (tags/Apple/clang-418.0.60)]

          platform: darwin

所需依赖

             numpy: 1.6.1

                    * Could not find the headers for numpy.  You may

                    * need to install the development package.

编辑:最终解决了。我需要安装gfortran和gcc编译器。使用brew安装即可,一切都像魔法般顺利!


从源代码构建应该没问题(至少使用来自git的最新版本)。但是您需要确保numpy的头文件在链接器路径中。 - tiago
4个回答

4
在Mountain Lion上安装matplotlib需要安装matplotlib的开发版本。 尝试使用pip install git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev 可能需要numpy 1.6.2才能正常工作。 通常,对于Mountain Lion,您可以在此链接中找到很好的建议和一个详细的逐步安装numpy/scipy/matplotlib/IPhython的过程。

1
你可能想将它固定到适用于Mac的最新标签:git+git://github.com/matplotlib/matplotlib.git@v1.1.1@egg=matplotlib - jterrace

2

最终解决了。我需要安装gfortran和gcc编译器。使用brew安装后,一切都像魔法般地运行良好!


1
你是怎么安装gcc和fortran的?我在brew里找到了gfortran,但没有找到gcc。另外,你是直接安装了matplotlib还是需要先运行pip install --upgrade numpy命令? - metakermit
@kermit666,它在brew中。 - Peter
谢谢,@Peter。虽然可能晚了一年 :) 这是对我有用的教程:http://www.thisisthegreenroom.com/2011/installing-python-numpy-scipy-matplotlib-and-ipython-on-lion/ - metakermit

0

对于 macOS 系统,使用 MacPorts 或 Brew 是最好的方式。这是我的经验。


-1
安装numpy。
pip install numpy

它应该为您解决依赖关系 - 我不确定为什么它没有起作用。


我已经安装了numpy。无论如何,我再次尝试,它说要求已满足。刚刚用numpy试过了。 - Amitash
您是否安装了numpy-dev软件包? - Dhaivat Pandya

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