我花了最近几个晚上尝试使用gcc-4.2和Python2.6在Mac OSX Lion上安装py2cairo,尝试了这些链接中提到的一些方法(以及其他许多方法;作为新用户,我可以发布只有两个链接):
http://www.niconomicon.net/blog/2011/10/09/2120.wrestling.python.snow.leopard
How to install PyCairo 1.10 on Mac OSX with default python
不幸的是,我仍然遇到错误的头文件被发现的问题。请参阅下面的我的环境设置和waf构建的错误输出。我非常感谢任何指针。谢谢!
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ env
MANPATH=/sw/share/man:/usr/share/man:/usr/local/share/man:/usr/X11/man:/usr/local/mysql/man:/sw/lib/perl5/5.12.3/man:/usr/X11R6/man
TERM_PROGRAM=Apple_Terminal
TERM=xterm-256color
SHELL=/bin/bash
TMPDIR=/var/folders/8r/2kt_yqyx2dg2g83m0dyhcy740000gn/T/
LIBRARY_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/lib
PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
Apple_PubSub_Socket_Render=/tmp/launch-bnnjZo/Render
TERM_PROGRAM_VERSION=303
OLDPWD=/private/tmp
TERM_SESSION_ID=3A9C4E28-D669-4134-A333-A13920514ED7
USER=dr_steve_kramer
LD_LIBRARY_PATH=/Library/Frameworks/Python.framework/Versions/6.3/lib:/Library/Frameworks/Python.framework/Versions/6.3:
COMMAND_MODE=unix2003
SSH_AUTH_SOCK=/tmp/launch-c3CJUO/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0:0
Apple_Ubiquity_Message=/tmp/launch-pYg8fw/Apple_Ubiquity_Message
PATH=/Library/Frameworks/Python.framework/Versions/6.3/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin:/usr/local/mysql/bin:/usr/local/bin/f2j-0.7/bin:/usr/local/jaxws-ri:/usr/X11R6/bin
MKL_NUM_THREADS=1
C_INCLUDE_PATH=/Developer/SDKs/MacOSX10.6.sdk/usr/include
PWD=/private/tmp/py2cairo-1.10.0
LANG=en_US.UTF-8
JAXWS_HOME=/usr/local/jaxws-ri
CXX=g++-4.2
SHLVL=1
HOME=/Users/dr_steve_kramer
CFLAGS=-I/usr/include/gcc/darwin/4.2/
LINKFLAGS=-search_dylibs_first -L /Library/Frameworks/Python.framework/Versions/6.3/lib/
PYTHONPATH=/Library/Frameworks/Python.framework/Versions/6.3/bin
LOGNAME=dr_steve_kramer
ACLOCAL_FLAGS=-I/usr/local/Cellar/pkg-config/0.25/share/aclocal
PKG_CONFIG_PATH=/sw/bin/pkg-config
ARCHFLAGS=-arch x86_64
INFOPATH=/sw/share/info:/sw/info:/usr/share/info
CC=/usr/bin/gcc-4.2
DISPLAY=/tmp/launch-CzK5Wg/org.x:0
_=/usr/bin/env
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf configure
./options()
Setting top to : /private/tmp/py2cairo-1.10.0
Setting out to : /private/tmp/py2cairo-1.10.0/build_directory
./configure()
Checking for 'gcc' (c compiler) : ok
Checking for program python : /Library/Frameworks/Python.framework/Versions/6.3/bin/python
python executable '/Library/Frameworks/Python.framework/Versions/6.3/bin/python' different from sys.executable '/Library/Frameworks/Python.framework/Versions/6.3/Resources/Python.app/Contents/MacOS/Python'
Checking for python version : (2, 6, 6, 'final', 0)
Checking for library python2.6 : yes
Checking for program python2.6-config : /Library/Frameworks/Python.framework/Versions/6.3/bin/python2.6-config
Checking for header Python.h : yes
Checking for program pkg-config : /sw/bin/pkg-config
Checking for 'cairo' >= 1.10.0 : yes
Configuration:
PREFIX : /usr/local
LIBDIR : /usr/local/lib
'configure' finished successfully (1.577s)
Steves-Mac-Pro:py2cairo-1.10.0 dr_steve_kramer$ python2.6 waf build
./options()
Waf: Entering directory `/private/tmp/py2cairo-1.10.0/build_directory'
./build()
src/build()
[1/9] c: src/cairomodule.c -> build_directory/src/cairomodule.c.1.o
[2/9] c: src/context.c -> build_directory/src/context.c.1.o
[3/9] c: src/font.c -> build_directory/src/font.c.1.o
[4/9] c: src/path.c -> build_directory/src/path.c.1.o
[5/9] c: src/pattern.c -> build_directory/src/pattern.c.1.o
[6/9] c: src/matrix.c -> build_directory/src/matrix.c.1.o
[7/9] c: src/surface.c -> build_directory/src/surface.c.1.o
[8/9] subst: pycairo.pc.in -> pycairo.pc
In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from ../src/pattern.c:32,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from ../src/surface.c:32,
from ../src/matrix.c:32In file included from /Library/Frameworks/Pyth:
:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85on.framework/Versions/6.3/include/python2.6/unicodeobject.h:4In file included from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:4,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85/usr/include/gcc/darwin/4.2/stdarg.h:5:2: ,
from ../src/cairomodule.c:32:
error: :
,
from ../src/path.c:32 /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85#error ,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85"This header only supports __MWERKS__." :
,
from ../src/context.c:32error: /usr/include/gcc/darwin/4.2/stdarg.h:5:2:,
from ../src/font.c:32error:
#error /usr/include/gcc/darwin/4.2/stdarg.h:5:2::
:
"This header only supports __MWERKS__." #error /usr/include/gcc/darwin/4.2/stdarg.h:5:2:/usr/include/gcc/darwin/4.2/stdarg.h:5:2:
"This header only supports __MWERKS__."error: #error
error: "This header only supports __MWERKS__."#error error: error:
"This header only supports __MWERKS__."#error #error
"This header only supports __MWERKS__.""This header only supports __MWERKS__."
In file included from /Developer/SDKs/MacOSX10.6.sdk/usr/include/wchar.h:111,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/unicodeobject.h:120,
from /Library/Frameworks/Python.framework/Versions/6.3/include/python2.6/Python.h:85,
from ../src/matrix.c:32:
/usr/include/gcc/darwin/4.2/stdarg.h:5:2: error: #error "This header only supports __MWERKS__."
答案 0 :(得分:0)
如果您尚未解决此问题,请尝试使用cairocffi:http://packages.python.org/cairocffi/
答案 1 :(得分:0)
如果有人在OSX上仍然遇到py2cairo问题。我能够通过使用install_name_tool来运行。配置/构建过程正在运行并找到正确版本的python。但是编译后的二进制文件与python的错误版本相关联。这似乎是waf构建系统中的一个错误。
解决问题......
$ cd /usr/local/lib/python2.7/site-packages/cairo
$ otool -L _cairo.so
_cairo.so:
/Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
$ sudo install_name_tool -change /System/Library/Frameworks/Python.framework/Versions/2.7/Python /Library/Frameworks/Python.framework/Versions/2.7/Python _cairo.so
$ otool -L _cairo.so
_cairo.so:
/Users/charlie/Downloads/py2cairo/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
/usr/local/lib/libcairo.2.dylib (compatibility version 11403.0.0, current version 11403.2.0)
/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.6)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
然后,您可以在运行waf脚本的python版本中导入和使用cairo。