SSL error installing pycurl after SSL is set

跟風遠走 提交于 2019-12-03 10:41:48
Andrei

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.

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.

You also need "dev tools" (headers/libraries) for openssl.

Also try the last release of pycurl, it might work out of the box.

to add a little update to the right answer given by @Andrei, I would say that last command need to force redownload and setup execution by adding no-cache-dir to pip install

pip install --no-cache-dir --compile pycurl

This will force complete compile.

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

Assuming you have openssl installed via homebrew, check brew info openssl. You may need to include some compilation flags via env-vars to use it, like many "keg-only" libs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!