Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL error installing pycurl after SSL is set

Just some information to start:

  • I'm running Mac OS 10.7.5
  • I have curl 7.21.4 installed (came with dev tools I believe)
  • I have python 2.7.1

I've been trying to get pycurl installed, but every time I try to run it, I get:

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

I first installed pycurl using the setup:

python setup.py install

Which didn't work (since SSL wasn't configured).

I have since uninstalled pycurl (sudo rm -rf /Library/Python/2.7/site-packages/pycurl*) before attempting:

export PYCURL_SSL_LIBRARY=openssl
easy-install pycurl

and again before trying:

python setup.py --with-ssl install

However, I'm still getting the same error that ssl is not compiled in. It's as if all the instructions are ignoring my attempts.

setup.py doesn't complain at all when installing, but easy install prints this message after I set the PYCURL_SSL_LIBRARY env var:

src/pycurl.c:151:4: warning: #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"

which seems to indicate it's completely ignoring the fact I just told it to install with openssl...

Is there something I'm missing in the setup?

like image 337
nivekmai Avatar asked Jan 31 '14 18:01

nivekmai


3 Answers

I had to use the following on CentOS 7:

sudo pip install --no-cache-dir --compile --ignore-installed --install-option="--with-nss" pycurl

No uninstall necessary or setting PYCURL_SSL_LIBRARY. Everything is baked into that one line.

like image 175
davidbitton Avatar answered Nov 10 '22 13:11

davidbitton


When you get:
    failed: ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)

You need to recompile pycurl with the PYCURL_SSL_LIBRARY properly set. The reinstall seems to be a two stage process.

It seems that pip downloads the stuff somewhere, compiles it and then puts it where python can use it. If you have the compiled version in the cache you are literally screwed because it will not recompile. It "gives" python the same thing, regardless of what is in the PYCURL_SSL_LIBRARY variable.

The solution is quite simple, erase the cache to force it to recompile. Depending on your operating system, the cache might be located in several places. You could go and search for it using the fact that there is a setup.py. It has the PACKAGE = "pycurl" string in it. But there is no need for all this trouble. The latest pip version supports an install --compile option.

Upgrade to the latest pip:
    pip install --upgrade pip #Healthy anyway

Remove the current pycurl with:
    pip uninstall pycurl

Set your PYCURL_SSL_LIBRARY as you need:
    export PYCURL_SSL_LIBRARY=nss #For me this was the required setting

Finally run
    pip install --compile pycurl

Note that you might need some -devel packages for the various header files needed in the compilation process.

like image 35
Andrei Avatar answered Nov 10 '22 13:11

Andrei


for mac, sudo pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl thank

like image 1
sinjon666 Avatar answered Nov 10 '22 13:11

sinjon666