I tried to install matplotlib on my MacBook Air, but it always gives me this error message:
我试图在我的MacBook Air上安装matplotlib,但它总是给我一个错误信息:
Processing matplotlib-1.1.1_notests.tar.gz
Running matplotlib-1.1.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-3jFpXK/matplotlib-1.1.1/egg-dist-tmp-jC7QY3
basedirlist is: []
============================================================================
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
REQUIRED DEPENDENCIES
numpy: 1.6.1
freetype2: found, but unknown version (no pkg-config)
* WARNING: Could not find 'freetype2' headers in any
* of '.', './freetype2'.
OPTIONAL BACKEND DEPENDENCIES
libpng: found, but unknown version (no pkg-config)
* Could not find 'libpng' headers in any of '.'
Tkinter: Tkinter: version not identified, Tk: 8.5, Tcl: 8.5
Gtk+: no
* Building for Gtk+ requires pygtk; you must be able
* to "import gtk" in your build/install environment
Mac OS X native: yes
Qt: no
Qt4: no
PySide: no
Cairo: no
OPTIONAL DATE/TIMEZONE DEPENDENCIES
datetime: present, version unknown
dateutil: 1.5
pytz: matplotlib will provide
adding pytz
OPTIONAL USETEX DEPENDENCIES
dvipng: 1.14
ghostscript: 9.05
latex: 3.1415926
[Edit setup.cfg to suppress the above messages]
pymods ['pylab']
packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz']
warning: no files found matching 'KNOWN_BUGS'
warning: no files found matching 'INTERACTIVE'
warning: no files found matching 'MANIFEST'
warning: no files found matching '__init__.py'
warning: no files found matching 'examples/data/*'
warning: no files found matching 'lib/mpl_toolkits'
warning: no files found matching 'LICENSE*' under directory 'license'
clang: warning: argument unused during compilation: '-mno-fused-madd'
In file included from src/ft2font.cpp:3:
src/ft2font.h:16:10: fatal error: 'ft2build.h' file not found
**#include <ft2build.h>
^
1 error generated.
error: Setup script exited with error: command 'clang' failed with exit status 1**
I tried to install freetype and libpng using homebrew but it doesn't work. How can I get ft2build.h?
我尝试使用homebrew安装freetype和libpng,但它不起作用。如何得到ft2building。h?
11 个解决方案
#1
36
The following worked for matplotlib installation after installing python according to instructions from thegreenroom. Those instructions didn't work for me after I installed Python. I followed the instructions from Scipy.org to install numpy and scipy. Then I did (adapted from above answer):
根据greenroom的说明,安装python之后,下面的代码用于matplotlib的安装。在我安装了Python之后,这些指令对我不起作用。我按照Scipy.org上的说明安装numpy和scipy。然后我做了(改编自上面的回答):
brew install freetype
brew install libpng
However I got the same error message whether I installed with pip install matplotlib
or trying to install from source, doing
但是,无论我安装了pip install matplotlib还是试图从源代码安装,我都得到了相同的错误消息
python setup.py build
python setup.py install
in the matplotlib directory I cloned via git clone https://github.com/matplotlib/matplotlib.git
.
在matplotlib目录中,我通过git克隆了https://github.com/matplotlib/matplotlib.git。
The error persisted until I ran
错误一直持续到我跑
brew link freetype
Then from the cloned matplotlib directory I ran
然后从克隆的matplotlib目录中运行
python setup.py build
python setup.py install
And the installation succeeded.
和安装成功了。
#2
25
This may help folks looking for a non-homebrew solution.
这可能有助于人们寻找非自制的解决方案。
My goal: use pip install
to build matplotlib for a non-system python 2.7.3 build.
我的目标是:使用pip安装为非系统python 2.7.3构建matplotlib。
Using latest X-Code and X-Code command line tools as of Feb 2013, no matter what gymnastics I tried, I always received C++ ostream related template errors when compiling ft2build with gcc.
在2013年2月,使用最新的X-Code和X-Code命令行工具,无论我尝试了什么,在编译与gcc的ft2build时,我总是收到c++ ostream相关的模板错误。
I was able to get a pip install to work with the following env vars:
我可以得到一个pip安装,以配合下列env vars:
export CC=clang
export CXX=clang++
export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2"
I simply forced clang and added my xquartz paths. No extra pkg-config or libpng builds, no sudo-ed symlinks.
我只是强行加入了clang并添加了xquartz路径。没有额外的pkg-config或libpng构建,没有sudo-ed符号链接。
#3
8
I think the other answers are on the right track, but I encountered this same problem and can attest that:
我认为其他的答案是正确的,但是我遇到了同样的问题,可以证明:
brew install pkg-config
brew install freetype
pip install matplotlib
would yield the same result. Typically on an Ubuntu box my next response would have been
会产生同样的结果。通常在Ubuntu框上,我的下一个反应是
sudo apt-get install libfreetype-dev
or some variation of that to install the header. However, I could find no such homebrew package. Furthermore, I was able to locate the header file in question in a pretty normal location on my system:
或者安装头文件的一些变体。然而,我找不到这样的自制程序包。此外,我能够在我的系统中一个非常正常的位置找到问题的头文件:
zoidberg:~ matt$ locate ft2build.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ft2build.h
/usr/X11/include/ft2build.h
So I suspect there's either a problem with my system paths or with the homebrew packaged matplotlib. Since I'm lazy, I just tried installing the matplotlib package head from github:
所以我怀疑我的系统路径或自制的打包matplotlib有问题。由于我很懒,所以我尝试从github上安装matplotlib包头:
pip install git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
and it worked for me.
这对我很有效。
#4
4
Here's the brew + pip recipe I used from a cold start. If you already have python and gfortran and such, jump in at the point where you need. The crucial steps appear to be brew install freetype
and brew install libpng
prior to doing pip install matplotlib
这是我从冷开始使用的brew + pip配方。如果您已经有了python和gfortran等语言,请在需要的地方进行跳转。关键的步骤似乎是在执行pip安装matplotlib之前,先安装brew freetype和brew安装libpng
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
$ brew doctor
$ brew install python
$ export PATH=/usr/local/bin:/usr/local/share/python:$PATH
$ easy_install pip
$ brew install gfortran
$ pip install numpy
$ pip install scipy
$ brew install pkg-config
$ brew install freetype
$ brew install libpng
$ pip install matplotlib
$ python
>>> import numpy
>>> import scipy
>>> import matplotlib
#5
2
Note the 'no pkg-config' notices. You should have pkg-config
on your search path, and it presumably needs to be the homebrew version so that it knows where the homebrew versions of the libraries are.
注意“无pkg-config”通知。您应该在搜索路径上设置pkg-config,它可能需要是自制版本,以便它知道库的自制版本在哪里。
#6
2
You need freetype:
你需要freetype的:
brew install freetype
See the following:
见以下:
http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394
http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394
#7
1
I also use mac air with OS X ver 10.8.2.
我还使用mac air和OS X ver 10.8.2。
Using following commands can get rid of this failure:
brew install freetype
brew install libpng
pip install matplotlib
使用以下命令可以清除此故障:brew安装freetype brew安装libpng pip安装matplotlib。
That's all. There may be some warning in the installing process, but that does not affect.
这是所有。在安装过程中可能会有一些警告,但这并不影响。
Use following python code to test:
使用以下python代码进行测试:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
which is referred from the url: http://matplotlib.org/users/pyplot_tutorial.html.
它来自url: http://matplotlib.org/users/pyplot_tutorial.html。
#8
0
I have found installing these pacakges via homebrew to be the most reliable method
我发现通过homebrew安装这些pacakges是最可靠的方法
# if you haven't installed python via brew already:
brew install python
# sets up python as default python instead of system python
brew link python
# Add more brew formulae so we can install our py libs with brew
brew tap samueljohn/python
brew tap homebrew/science
# install numpy,scipy,matplotlib and dependencies ( gfortran, etc.. )
brew install numpy
brew install scipy
brew insatll matplotlib
#9
0
I am using MacOs 10.8 too, and I encountered the same problem regarding not finding ft2build.h header when I tried to install matplotlib, what I l did to resolve the reported issue is :
我也在使用MacOs 10.8,在没有找到ft2build时遇到了同样的问题。h header当我尝试安装matplotlib时,我为解决报告的问题所做的是:
1) replacing "ft2build.h" in the following call within the file "setupext.py" :
1)取代“ft2build。h在文件“setupext”中的以下调用。py”:
return self._check_for_pkg_config('freetype2',
'ft2build.h',
min_version='2.4',
version=version)
by the complete path to the ft2build.h header, in my case :
通过ft2build的完整路径。h标头,在我的例子中:
return self._check_for_pkg_config('freetype2',
'/usr/local/Cellar/freetype/2.5.2/include/freetype2/ft2build.h',
min_version='2.4',
version=version)
#10
0
I think, but have not tested, that the problem is solved in an upstream commit of matplotlib. Here is my reasons why:
我认为,这个问题在matplotlib的上游提交中得到了解决,但还没有经过测试。以下是我的理由:
Discussion:
讨论:
https://github.com/vbraun/sage/commit/5d17ca989eb58559af8f43b43e368c378c1bf6bb
https://github.com/vbraun/sage/commit/5d17ca989eb58559af8f43b43e368c378c1bf6bb
Fix:
解决办法:
https://github.com/vbraun/sage/blob/5d17ca989eb58559af8f43b43e368c378c1bf6bb/build/pkgs/matplotlib/patches/pkg-config.patch
I fixed the problem with Cyris's answer thought.
我修正了西里斯回答的问题。
#11
-1
I also had a similar issue, and fixed it in a reasonably straightforward way using homebrew.
我也有一个类似的问题,用自制的方法用一种相当简单的方式解决了这个问题。
You don't have to link the freetype
libraries for this reason. The main problem is, after you install freetype
using homebrew, you are told to add
由于这个原因,您不必链接*类型库。主要的问题是,在使用homebrew安装freetype之后,需要添加
-I/usr/local/opt/freetype/include
to your CPPFLAGS. However, this alone is not sufficient, and you also have to add the the freetype2
subfolder as well.
CPPFLAGS。但是,仅这一点是不够的,您还必须添加freetype2子文件夹。
So in order to install matplotlib, do this:
因此,为了安装matplotlib,请这样做:
brew install freetype
brew install libpng
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" pip install matplotlib
#1
36
The following worked for matplotlib installation after installing python according to instructions from thegreenroom. Those instructions didn't work for me after I installed Python. I followed the instructions from Scipy.org to install numpy and scipy. Then I did (adapted from above answer):
根据greenroom的说明,安装python之后,下面的代码用于matplotlib的安装。在我安装了Python之后,这些指令对我不起作用。我按照Scipy.org上的说明安装numpy和scipy。然后我做了(改编自上面的回答):
brew install freetype
brew install libpng
However I got the same error message whether I installed with pip install matplotlib
or trying to install from source, doing
但是,无论我安装了pip install matplotlib还是试图从源代码安装,我都得到了相同的错误消息
python setup.py build
python setup.py install
in the matplotlib directory I cloned via git clone https://github.com/matplotlib/matplotlib.git
.
在matplotlib目录中,我通过git克隆了https://github.com/matplotlib/matplotlib.git。
The error persisted until I ran
错误一直持续到我跑
brew link freetype
Then from the cloned matplotlib directory I ran
然后从克隆的matplotlib目录中运行
python setup.py build
python setup.py install
And the installation succeeded.
和安装成功了。
#2
25
This may help folks looking for a non-homebrew solution.
这可能有助于人们寻找非自制的解决方案。
My goal: use pip install
to build matplotlib for a non-system python 2.7.3 build.
我的目标是:使用pip安装为非系统python 2.7.3构建matplotlib。
Using latest X-Code and X-Code command line tools as of Feb 2013, no matter what gymnastics I tried, I always received C++ ostream related template errors when compiling ft2build with gcc.
在2013年2月,使用最新的X-Code和X-Code命令行工具,无论我尝试了什么,在编译与gcc的ft2build时,我总是收到c++ ostream相关的模板错误。
I was able to get a pip install to work with the following env vars:
我可以得到一个pip安装,以配合下列env vars:
export CC=clang
export CXX=clang++
export LDFLAGS="-L/usr/X11/lib"
export CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2"
I simply forced clang and added my xquartz paths. No extra pkg-config or libpng builds, no sudo-ed symlinks.
我只是强行加入了clang并添加了xquartz路径。没有额外的pkg-config或libpng构建,没有sudo-ed符号链接。
#3
8
I think the other answers are on the right track, but I encountered this same problem and can attest that:
我认为其他的答案是正确的,但是我遇到了同样的问题,可以证明:
brew install pkg-config
brew install freetype
pip install matplotlib
would yield the same result. Typically on an Ubuntu box my next response would have been
会产生同样的结果。通常在Ubuntu框上,我的下一个反应是
sudo apt-get install libfreetype-dev
or some variation of that to install the header. However, I could find no such homebrew package. Furthermore, I was able to locate the header file in question in a pretty normal location on my system:
或者安装头文件的一些变体。然而,我找不到这样的自制程序包。此外,我能够在我的系统中一个非常正常的位置找到问题的头文件:
zoidberg:~ matt$ locate ft2build.h
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/X11/include/ft2build.h
/usr/X11/include/ft2build.h
So I suspect there's either a problem with my system paths or with the homebrew packaged matplotlib. Since I'm lazy, I just tried installing the matplotlib package head from github:
所以我怀疑我的系统路径或自制的打包matplotlib有问题。由于我很懒,所以我尝试从github上安装matplotlib包头:
pip install git+git://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev
and it worked for me.
这对我很有效。
#4
4
Here's the brew + pip recipe I used from a cold start. If you already have python and gfortran and such, jump in at the point where you need. The crucial steps appear to be brew install freetype
and brew install libpng
prior to doing pip install matplotlib
这是我从冷开始使用的brew + pip配方。如果您已经有了python和gfortran等语言,请在需要的地方进行跳转。关键的步骤似乎是在执行pip安装matplotlib之前,先安装brew freetype和brew安装libpng
$ ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
$ brew doctor
$ brew install python
$ export PATH=/usr/local/bin:/usr/local/share/python:$PATH
$ easy_install pip
$ brew install gfortran
$ pip install numpy
$ pip install scipy
$ brew install pkg-config
$ brew install freetype
$ brew install libpng
$ pip install matplotlib
$ python
>>> import numpy
>>> import scipy
>>> import matplotlib
#5
2
Note the 'no pkg-config' notices. You should have pkg-config
on your search path, and it presumably needs to be the homebrew version so that it knows where the homebrew versions of the libraries are.
注意“无pkg-config”通知。您应该在搜索路径上设置pkg-config,它可能需要是自制版本,以便它知道库的自制版本在哪里。
#6
2
You need freetype:
你需要freetype的:
brew install freetype
See the following:
见以下:
http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394
http://comments.gmane.org/gmane.comp.python.matplotlib.general/31394
#7
1
I also use mac air with OS X ver 10.8.2.
我还使用mac air和OS X ver 10.8.2。
Using following commands can get rid of this failure:
brew install freetype
brew install libpng
pip install matplotlib
使用以下命令可以清除此故障:brew安装freetype brew安装libpng pip安装matplotlib。
That's all. There may be some warning in the installing process, but that does not affect.
这是所有。在安装过程中可能会有一些警告,但这并不影响。
Use following python code to test:
使用以下python代码进行测试:
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
which is referred from the url: http://matplotlib.org/users/pyplot_tutorial.html.
它来自url: http://matplotlib.org/users/pyplot_tutorial.html。
#8
0
I have found installing these pacakges via homebrew to be the most reliable method
我发现通过homebrew安装这些pacakges是最可靠的方法
# if you haven't installed python via brew already:
brew install python
# sets up python as default python instead of system python
brew link python
# Add more brew formulae so we can install our py libs with brew
brew tap samueljohn/python
brew tap homebrew/science
# install numpy,scipy,matplotlib and dependencies ( gfortran, etc.. )
brew install numpy
brew install scipy
brew insatll matplotlib
#9
0
I am using MacOs 10.8 too, and I encountered the same problem regarding not finding ft2build.h header when I tried to install matplotlib, what I l did to resolve the reported issue is :
我也在使用MacOs 10.8,在没有找到ft2build时遇到了同样的问题。h header当我尝试安装matplotlib时,我为解决报告的问题所做的是:
1) replacing "ft2build.h" in the following call within the file "setupext.py" :
1)取代“ft2build。h在文件“setupext”中的以下调用。py”:
return self._check_for_pkg_config('freetype2',
'ft2build.h',
min_version='2.4',
version=version)
by the complete path to the ft2build.h header, in my case :
通过ft2build的完整路径。h标头,在我的例子中:
return self._check_for_pkg_config('freetype2',
'/usr/local/Cellar/freetype/2.5.2/include/freetype2/ft2build.h',
min_version='2.4',
version=version)
#10
0
I think, but have not tested, that the problem is solved in an upstream commit of matplotlib. Here is my reasons why:
我认为,这个问题在matplotlib的上游提交中得到了解决,但还没有经过测试。以下是我的理由:
Discussion:
讨论:
https://github.com/vbraun/sage/commit/5d17ca989eb58559af8f43b43e368c378c1bf6bb
https://github.com/vbraun/sage/commit/5d17ca989eb58559af8f43b43e368c378c1bf6bb
Fix:
解决办法:
https://github.com/vbraun/sage/blob/5d17ca989eb58559af8f43b43e368c378c1bf6bb/build/pkgs/matplotlib/patches/pkg-config.patch
I fixed the problem with Cyris's answer thought.
我修正了西里斯回答的问题。
#11
-1
I also had a similar issue, and fixed it in a reasonably straightforward way using homebrew.
我也有一个类似的问题,用自制的方法用一种相当简单的方式解决了这个问题。
You don't have to link the freetype
libraries for this reason. The main problem is, after you install freetype
using homebrew, you are told to add
由于这个原因,您不必链接*类型库。主要的问题是,在使用homebrew安装freetype之后,需要添加
-I/usr/local/opt/freetype/include
to your CPPFLAGS. However, this alone is not sufficient, and you also have to add the the freetype2
subfolder as well.
CPPFLAGS。但是,仅这一点是不够的,您还必须添加freetype2子文件夹。
So in order to install matplotlib, do this:
因此,为了安装matplotlib,请这样做:
brew install freetype
brew install libpng
LDFLAGS="-L/usr/local/opt/freetype/lib -L/usr/local/opt/libpng/lib" CPPFLAGS="-I/usr/local/opt/freetype/include -I/usr/local/opt/libpng/include -I/usr/local/opt/freetype/include/freetype2" pip install matplotlib