我的应用需要使用PyCurl,所以我尝试在我的Mac上安装它,但我发现了很多问题和错误。
要求: 首先,我必须说我的Mac上运行的Python版本是基于32位的,因为我需要使用需要32位Python的WxPython。 为此,我使用了:
defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
安装我使用的PyCurl:
sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl
终点站回来了:
Best match: setuptools 0.6c11
Processing setuptools-0.6c11-py2.6.egg
setuptools 0.6c11 is already the active version in easy-install.pth
Installing easy_install script to /usr/local/bin
Installing easy_install-2.6 script to /usr/local/bin
Using /Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg
Processing dependencies for setuptools
Finished processing dependencies for setuptools
Searching for pycurl
Best match: pycurl 7.16.2.1
Processing pycurl-7.16.2.1-py2.6-macosx-10.6-universal.egg
pycurl 7.16.2.1 is already the active version in easy-install.pth
Using /Library/Python/2.6/site-packages/pycurl-7.16.2.1-py2.6-macosx-10.6-universal.egg
Processing dependencies for pycurl
Finished processing dependencies for pycurl
所以我认为pycurl已正确安装并正常工作,但是当我启动应用程序时,python返回错误:
python /Users/lorenzodenobili/Desktop/Python/AGGIORNATORE_PY/Dropbox/wxPython/test.py
Traceback (most recent call last):
File "/Users/lorenzodenobili/Desktop/Python/AGGIORNATORE_PY/Dropbox/wxPython/test.py", line 20, in <module>
import pycurl
File "build/bdist.macosx-10.6-universal/egg/pycurl.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/pycurl.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/lorenzodenobili/.python-eggs/pycurl-7.16.2.1-py2.6-macosx-10.6-universal.egg-tmp/pycurl.so, 2): no suitable image found. Did find:
/Users/lorenzodenobili/.python-eggs/pycurl-7.16.2.1-py2.6-macosx-10.6-universal.egg-tmp/pycurl.so: mach-o, but wrong architecture
我真的不知道如何解决这个错误,所以我真的需要你的帮助!
答案 0 :(得分:2)
尝试从pip和easy_install安装时遇到了同样的问题。我通过下载pycurl源并为Snow Leopard编译来安装和工作。在pycurl源目录中,在运行“python setup.py install”之前,如install.txt所说,你需要运行它:
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c src/pycurl.c -o build/temp.macosx-10.6-universal-2.6/src/pycurl.o
基本上,-arch PPC
的编译标记与EXCEPT相同,导致它在Snow Leopard上失败。
运行上面的命令后,您就可以运行:
python setup.py install
它应该都有效。
答案 1 :(得分:1)
编译PyCurl时,您将以下标志传递给编译器:
ARCHFLAGS="-arch x86_64"
您使用32位Python似乎已经在64位模式下编译了PyCurl。你试过ARCHFLAGS="-arch i386"
吗?
答案 2 :(得分:-1)
iMac:pycurl-7.19.0 lorenzodenobili $ sudo env ARCHFLAGS =“ - arch i386”easy_install setuptools pycurl 正在搜索setuptools 最佳匹配:setuptools 0.6c11 处理setuptools-0.6c11-py2.6.egg setuptools 0.6c11已经是easy-install.pth中的活动版本 将easy_install脚本安装到/ usr / local / bin 将easy_install-2.6脚本安装到/ usr / local / bin
使用/Library/Python/2.6/site-packages/setuptools-0.6c11-py2.6.egg 处理setuptools的依赖关系 已完成处理setuptools的依赖关系 正在搜索pycurl 阅读http://pypi.python.org/simple/pycurl/ 阅读http://pycurl.sourceforge.net/ 阅读http://pycurl.sourceforge.net/download/ 最佳匹配:pycurl 7.19.0 正在下载http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar.gz 处理pycurl-7.19.0.tar.gz 运行pycurl-7.19.0 / setup.py -q bdist_egg --dist-dir /tmp/easy_install-tpClDx/pycurl-7.19.0/egg-dist-tmp-bGXtsd 使用curl-config(libcurl 7.20.0) 在/opt/local/include/curl/curl.h:36中包含的文件中, 来自src / pycurl.c:50: /opt/local/include/curl/curlrules.h:144:错误:数组' curl_rule_01 '的大小为负数 /opt/local/include/curl/curlrules.h:154:错误:数组' curl_rule_02 '的大小为负数 错误:安装脚本退出并显示错误:命令'gcc-4.2'失败,退出状态为1