我已经杀了半天试图在Snow Leopard上为python编译matplotlib。我已经使用了googles并找到了这个有用的页面(http://blog.hyperjeff.net/?p=160),但我还是无法编译。我看到该页面上其他用户的评论,所以我知道我并不孤单。
我已经独立安装了zlib,libpng和freetype。
我编辑了make.osx文件,将其包含在顶部:
PREFIX=/usr/local
PYVERSION=2.6
PYTHON=python${PYVERSION}
ZLIBVERSION=1.2.3
PNGVERSION=1.2.33
FREETYPEVERSION=2.3.5
MACOSX_DEPLOYMENT_TARGET=10.6
## You shouldn't need to configure past this point
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
CFLAGS="-Os -arch x86_64 -arch i386 -I${PREFIX}/include"
LDFLAGS="-arch x86_64 -arch i386 -L${PREFIX}/lib"
CFLAGS_DEPS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk"
LDFLAGS_DEPS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
然后我跑了:
sudo make -f make.osx mpl_build
给了我:
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig" &&\
export MACOSX_DEPLOYMENT_TARGET=10.6 &&\
export CFLAGS="-Os -arch x86_64 -arch i386 -I/usr/local/include" &&\
export LDFLAGS="-arch x86_64 -arch i386 -L/usr/local/lib" &&\
python2.6 setup.py build
... snip ...
gcc-4.2 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -Os -arch x86_64 -arch i386 -I/usr/local/include -pipe -DPY_ARRAYAUNIQUE_SYMBOL=MPL_ARRAY_API -I/Library/Python/2.6/site-packages/numpy/core/include -I. -I/Library/Python/2.6/site-packages/numpy/core/include/freetype2 -I./freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/ft2font.cpp -o build/temp.macosx-10.6-universal-2.6/src/ft2font.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
In file included from src/ft2font.h:13,
from src/ft2font.cpp:1:
/usr/local/include/ft2build.h:56:38: error: freetype/config/ftheader.h: No such file or directory
... snip ...
src/ft2font.cpp:98: error: ‘FT_Int’ was not declared in this scope
/Library/Python/2.6/site-packages/numpy/core/include/numpy/__multiarray_api.h:1174: warning: ‘int _import_array()’ defined but not used
lipo: can't open input file: /var/tmp//ccDOGx37.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1
make: *** [mpl_build] Error 1
我迷失了。
答案 0 :(得分:7)
根据您的错误消息,您丢失了freetype标头。您能使用系统搜索功能找到它们吗?我不打算使用预先构建的软件包,因为我喜欢抓头并从头开始编译。
答案 1 :(得分:6)
此解决方案适用于OSX 10.8.3:
ln -s /usr/local/include/freetype2/freetype/ /usr/include/freetype
(信用证实际上是:http://simpleyuan.blogspot.com/2012/08/matplotlib-error-mac-os-x.html)
答案 2 :(得分:3)
您也可以使用
进行构建$ python setup.py build
将以下补丁应用于setupext.py
Index: setupext.py
===================================================================
--- setupext.py (revision 7917)
+++ setupext.py (working copy)
@@ -334,6 +334,8 @@
module.include_dirs.extend(incdirs)
module.include_dirs.append('.')
+ module.include_dirs.append('/usr/local/include')
+ module.include_dirs.append('/usr/local/include/freetype2')
module.library_dirs.extend(libdirs)
def getoutput(s):
答案 3 :(得分:1)
对于Python.org 2.7.1:
我使用了各种说明。它基本上可以在OSX的/ usr / X11中使用libpng
下载,构建和安装(make install)freetype2 v2.4.4& zlib v1.2.5。 没有使用make deps。
修改后的setupext.py
module.include_dirs.extend(incdirs)
module.include_dirs.append('.')
module.include_dirs.append('/usr/local/include')
module.include_dirs.append('/usr/local/include/freetype2')
module.include_dirs.append('/usr/X11/include')
module.library_dirs.extend(libdirs)
module.library_dirs.append('/usr/local/lib')
module.library_dirs.append('/usr/X11/lib')
修改后的make.osx包含相同的/ usr / X11信息,png版本1.2.5是OSX 10.6.6当前原生
PYVERSION=2.7
PYTHON=python${PYVERSION}
ZLIBVERSION=1.2.5
PNGVERSION=1.2.44
FREETYPEVERSION=2.4.4
MACOSX_DEPLOYMENT_TARGET=10.6
OSX_SDK_VER=10.6
ARCH_FLAGS="-arch i386-arch x86_64"
PREFIX=/usr/local
MACPREFIX=/usr/X11
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
CFLAGS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -I${MAXPREFIX}/include -isysroot /Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
LDFLAGS="-arch i386 -arch x86_64 -L${PREFIX}/lib -L/usr/X11/lib -syslibroot,/Developer/SDKs/MacOSX${OSX_SDK_VER}.sdk"
FFLAGS="-arch i386 -arch x86_64"
然后标准
sudo make -f make.osx mpl_build
sudo make -f make.osx mpl_install
sudo python setup.py install
Crikey ......似乎有效。现在有了Image& MDP& pylab& matplotlib,2.7.6 on 10.6.6
只要安装libjpeg,图像模块(Imaging-1.7.7)就可以正常工作。我使用了jpegsrc.v8c
,看起来很开心。
答案 4 :(得分:0)
我刚刚编译好了。我在make.osx文件中的CFLAGS的include路径中添加了freetype2。现在,make.osx的顶部是:
PREFIX=/usr/local
PYVERSION=2.6
PYTHON=python${PYVERSION}
ZLIBVERSION=1.2.3
PNGVERSION=1.2.33
FREETYPEVERSION=2.3.5
MACOSX_DEPLOYMENT_TARGET=10.6
## You shouldn't need to configure past this point
PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig"
CFLAGS="-Os -arch x86_64 -arch i386 -I${PREFIX}/include -I${PREFIX}/include/freetype2"
LDFLAGS="-arch x86_64 -arch i386 -L${PREFIX}/lib"
CFLAGS_DEPS="-arch i386 -arch x86_64 -I${PREFIX}/include -I${PREFIX}/include/freetype2 -isysroot /Developer/SDKs/MacOSX10.6.sdk"
LDFLAGS_DEPS="-arch i386 -arch x86_64 -L${PREFIX}/lib -syslibroot,/Developer/SDKs/MacOSX10.6.sdk"
然后我运行了这些命令,并且编译和安装完美。
sudo make -f make.osx mpl_build
sudo make -f make.osx mpl_install
答案 5 :(得分:0)
正如其他地方所建议的那样,macports在多种体系结构上运行良好,MacOsX +版本允许更新等等:
$ port search matplot
py-matplotlib @0.99.0 (python, graphics, math)
matlab-like syntax for creating plots in python
py-matplotlib-basemap @0.99.4 (python, graphics, math)
matplotlib toolkit for plotting data on map projections
py25-matplotlib @0.99.0 (python, graphics, math)
matlab-like syntax for creating plots in python
py25-matplotlib-basemap @0.99.4 (python, graphics, math)
matplotlib toolkit for plotting data on map projections
py26-matplotlib @0.99.0 (python, graphics, math)
matlab-like syntax for creating plots in python
py26-matplotlib-basemap @0.99.4 (python, graphics, math)
matplotlib toolkit for plotting data on map projections
Found 6 ports.
$
在您的情况下,只需发出:
$ sudo port install py26-matplotlib
它将macosx后端(本机可可)作为默认值
答案 6 :(得分:-1)
你应该在matplotlib-users邮件列表中问这个问题。它由实际的matplotlib开发人员监控,StackOverflow(AFAIK)不是。