Pablo
Pablo

Reputation: 29519

pycurl error on Mac OS 10.8

I have installed pycurl using pip

oczml:~ acid$ sudo pip install pycurl
Password:
Downloading/unpacking pycurl
  Downloading pycurl-7.19.3.1.tar.gz (116kB): 116kB downloaded
  Running setup.py egg_info for package pycurl
    Using curl-config (libcurl 7.24.0)

Installing collected packages: pycurl
  Running setup.py install for pycurl
    Using curl-config (libcurl 7.24.0)
    building 'pycurl' extension
    clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -DPYCURL_VERSION="7.19.3.1" -DHAVE_CURL_SSL=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/pycurl.c -o build/temp.macosx-10.8-intel-2.7/src/pycurl.o
    clang: warning: argument unused during compilation: '-mno-fused-madd'
    src/pycurl.c:123:4: warning: "libcurl was compiled with SSL support, but configure could not determine which "    "library was used; thus no SSL crypto locking callbacks will be set, which may "    "cause random crashes on SSL requests" [-W#warnings]
    #  warning \
       ^
    1 warning generated.
    src/pycurl.c:123:4: warning: "libcurl was compiled with SSL support, but configure could not determine which "    "library was used; thus no SSL crypto locking callbacks will be set, which may "    "cause random crashes on SSL requests" [-W#warnings]
    #  warning \
       ^
    src/pycurl.c:1555:26: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                int sockfd = PyInt_AsLong(fileno_result);
                    ~~~~~~   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:1630:24: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
            int ret_code = PyInt_AsLong(result);
                ~~~~~~~~   ^~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:2447:31: warning: implicit conversion loses integer precision: 'long' to 'int' [-Wshorten-64-to-32]
                            val = PyLong_AsLong(PyTuple_GET_ITEM(t, j));
                                ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:3610:22: warning: implicit conversion loses integer precision: 'long' to '__darwin_suseconds_t' (aka 'int') [-Wshorten-64-to-32]
            tv.tv_usec = (long)(timeout*1000000.0);
                       ~ ^~~~~~~~~~~~~~~~~~~~~~~~~
    src/pycurl.c:4513:27: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        libcurl_version_len = strlen(libcurl_version);
                            ~ ^~~~~~~~~~~~~~~~~~~~~~~
    6 warnings generated.
    clang -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.8-intel-2.7/src/pycurl.o -lcurl -o build/lib.macosx-10.8-intel-2.7/pycurl.so

Successfully installed pycurl
Cleaning up...

But when I try to import pycurl, I get the following error:

ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)

Upvotes: 1

Views: 2050

Answers (2)

billybobza
billybobza

Reputation: 71

I had the same problem and solved the problem this way. Firstly I'm using Python3 and using pip3, but the same should work for pip.

I realised that I didn't have SSL installed or setup, so I went here: https://www.openssl.org/source/ and installed the latest OpenSSL. You install it the old unix way, which is you download the gzip file.

tar -zxvf openssl-1.0.2n.tar.gz

(your file might be a different version) then run:

./Configure darwin64-x86_64-cc

(this is for 64-bit Mac architecture only. run ./configure normally) Then:

make
make test
sudo make install

(Used sudo because it may need to create folders). Now you have OpenSSL installed. You need to install PyCurl and tell it about your header files for OpenSSL. I did that this way:

pip3 install pycurl --global-option=build_ext --global-option="-L/{OpenSSL-install-directory}/lib" --global-option="-I/{OpenSSL-install-directory}/include"

replace {OpenSSL-install-directory} with your actual path. Mine was /usr/local/ssl:

pip3 install pycurl --global-option=build_ext --global-option="-L/usr/local/ssl/lib" --global-option="-I/usr/local/ssl/include"

Then it installed and worked.

Used the following resources in piecing this together:

Upvotes: 1

mingaleg
mingaleg

Reputation: 2087

Reposted from SSL backend error when using OpenSSL

After reading their INSTALLATION file, I was able to solve my problem by setting an environment variable and did a reinstall

  • remove existing pycurl installation

    pip uninstall pycurl

  • export variable

    export PYCURL_SSL_LIBRARY=openssl

  • install pycurl

    pip install pycurl

There could be other solution out there but this works perfect for me on a virtualenv and pip installation

Upvotes: 2

Related Questions