这是我到目前为止所做的:
我已经安装了 Homebrew:
/usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"
然后是蟒蛇:brew install python
然后py2cairo:brew install py2cairo
这两个似乎都安装正确,当我输入时which python
我得到:usr/local/bin/python
我相信这是自制的版本。
正如许多 Homebrew 指南所建议的那样,我已经编辑了我的路径:
export PATH=/usr/local/bin:/usr/local/share/python:$PATH
这是我从中得到的echo $PATH
:/usr/local/bin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
我也可以输入python --version
并获取python 2.7.3
看起来正确的内容,因为如果我查看/usr/local/Cellar/py2cairo/1.10.0/README
它会说:
Dependencies
------------
cairo >= 1.10.0
Python >= 2.6
然而,毕竟这我仍然无法将 py2cairo 库导入 python。这是我尝试时得到的结果:
Sal:~ Lockyer$ python
Python 2.7.3 (default, May 6 2012, 13:47:31)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cairo
Fatal Python error: Interpreter not initialized (version mismatch?)
Abort trap: 6
我认为大多数人都使用pip
oreasy_install
来做这种事情,但我认为 py2cairo 不受这些支持。这是我跑步时得到的pip-2.7 install py2cairo
:
Downloading/unpacking py2cairo
Could not find any downloads that satisfy the requirement py2cairo
No distributions at all found for py2cairo
Storing complete log in /Users/Lockyer/Library/Logs/pip.log
我想我一定只是错过了最后一步,我以某种方式向 python 揭示了从哪里导入库......我忘记在我的路径中添加一些东西了吗?
这是我跑步时得到的ls -l /usr/local/bin/python
lrwxr-xr-x 1 Lockyer admin 33 6 May 13:48 /usr/local/bin/python -> ../Cellar/python/2.7.3/bin/python
这是我跑步时得到的otool -L /usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages/cairo/_cairo.so
:
/usr/local/Cellar/py2cairo/1.10.0/lib/python2.7/site-packages/cairo/_cairo.so:
/private/tmp/homebrew-py2cairo-1.10.0-BtmY/py2cairo-1.10.0/build_directory/src/_cairo.so (compatibility version 0.0.0, current version 0.0.0)
/usr/local/Cellar/cairo/1.10.2/lib/libcairo.2.dylib (compatibility version 11003.0.0, current version 11003.2.0)
/System/Library/Frameworks/Python.framework/Versions/2.7/Python (compatibility version 2.7.0, current version 2.7.1)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1094.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.1.0)
移动/System/Library/Frameworks/Python.framework/Versions
到我的桌面并brew install py2cairo
再次运行似乎已经修复了该错误。很高兴知道它为什么要针对 Lion 的 python 构建,因为它似乎不是第一个在路径上......