Problem installing PyCurl on Mac Snow Leopard

My application needs to use PyCurl, so I tried installing 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 running on my Mac is 32 bit based, because I need to use WxPython, which requires 32 bit Python. For 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 pycurl was installed correctly and working, but when I started the application, python returned 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 know how to solve this error, so I really need your help!

+6
python osx-snow-leopard importerror macos pycurl
source share
3 answers

I ran into the same problem when trying to install from pip and easy_install. I got it and worked by downloading the pycurl source and compiling for Snow Leopard. In the pycurl source directory, before running "python setup.py install", as 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, these are the same EXCEPT compilation flags for -arch PPC , which caused it to crash on Snow Leopard.

Once you run the command above, you can run:

 python setup.py install 

And everything should work.

+2
source share

When compiling PyCurl, you passed the following flags:

 ARCHFLAGS="-arch x86_64" 

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

+1
source share

iMac: pycurl-7.19.0 lorenzodenobili $ sudo env ARCHFLAGS = "- arch i386" easy_install setuptools pycurl Search for setuptools Best match: setuptools 0.6c11 Processing setuptools-0.6c11-py2.6.egg setuptools 0.6c11 is already an active version in easy- install.pth Install easy_install script in / usr / local / bin Install easy_install-2.6 script in / usr / local / bin

Using / Library / Python / 2.6 / site-packages / setuptools-0.6c11-py2.6.egg Dependency handling for setuptools Dependency handling for setuptools completed Search pycurl Read http://pypi.python.org/simple/pycurl/ Read http : //pycurl.sourceforge.net/ Read http://pycurl.sourceforge.net/download/ Best matches: pycurl 7.19.0 Download http://pycurl.sourceforge.net/download/pycurl-7.19.0.tar. gz Handling pycurl-7.19.0.tar.gz Starting pycurl-7.19.0 / setup.py -q bdist_egg --dist-dir / tmp / easy_install-tpClDx / pycurl-7.19.0 / egg-dist-tmp-bGXtsd Using curl-config (libcurl 7.20.0) In the file included in /opt/local/include/curl/curl.h:36, from src / pycurl.c: 50: /opt/local/include/curl/curlrules.h : 144: error: array size curl_rule_01 negative / opt / local / include / curl / curl rules.h: 154: error: array size curl_rule_02 negative Error: installation of script completed with error: command 'gcc-4.2' failed with exit status 1

-one
source share

All Articles