尝试在 Mac Snow Leopard 上安装 PyCurl 时出现问题

发布于 2024-08-31 18:46:56 字数 1975 浏览 3 评论 0原文

我的应用程序需要使用 PyCurl,因此我尝试将其安装在我的 Mac 上,但发现了很多问题和错误。

要求: 首先我必须说我的Mac上运行的Python版本是基于32位的,因为我需要使用WxPython,这需要32位Python。 为此,我使用:

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  

我真的不知道如何解决这个错误,所以我真的需要你的帮助!

My app needs to use PyCurl, so I tried to install it on my Mac but I found a lot of problems and errors.

Requirement:
First of all I have to say that the version of Python working on my Mac is 32 bit based, because I need to use WxPython, that needs 32 bit Python.
For doing this I used:

defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

To install PyCurl I used:

sudo env ARCHFLAGS="-arch x86_64" easy_install setuptools pycurl

And the terminal returned:

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

So I thought that pycurl was correctly installed and working, but when I started my app, python return me an error:

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  

I really don't have any idea on how to solve this error, so I really need your help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

停滞 2024-09-07 18:46:56

当我尝试从 pip 和 easy_install 安装时遇到了同样的问题。我通过下载 pycurl 源代码并为 Snow Leopard 进行编译来安装并运行它。在 pycurl 源目录中,在按照 install.txt 所示运行“python setup.py install”之前,您需要运行以下命令:

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 之外导致它在雪豹上失败。

运行上面的命令后,您可以运行:

python setup.py install

它应该一切正常。

I ran into the same issue when trying to install from pip and easy_install. I got it installed and working by downloading the pycurl source and compiling for Snow Leopard. In the pycurl source directory, before you run "python setup.py install" as the install.txt says, you need to run this:

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

Basically, it's the same compilation flags EXCEPT for -arch PPC, which was causing it to fail on Snow Leopard.

Once you run the command above, then you can run:

python setup.py install

And it should all be working.

顾挽 2024-09-07 18:46:56

编译 PyCurl 时,您将以下标志传递给编译器:

ARCHFLAGS="-arch x86_64"

看来您已在 64 位模式下编译了 PyCurl,而您使用的是 32 位 Python。您是否尝试过使用 ARCHFLAGS="-arch i386"

You passed the following flags to the compiler when compiling PyCurl:

ARCHFLAGS="-arch x86_64"

It seems that you have compiled PyCurl in 64-bit mode, while you use the 32-bit Python. Have you tried it with ARCHFLAGS="-arch i386"?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文