SSL backend error when using OpenSSL

2019-01-13 02:44发布

I was trying to install pycurl in a virtualenv using pip and I got this error

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

I read some documentation saying that "To fix this, you need to tell setup.py what SSL backend is used" (source) although I am not sure how to do this since I installed pycurl using pip.

How can I specify the SSL backend when installing pycurl with pip?

Thanks

21条回答
看我几分像从前
2楼-- · 2019-01-13 03:19

The method to fix the pycurl after Mac OS High Sierra update:

  1. Reinstall the curl libraries to use OpenSSL instead of SecureTransport

    brew install curl --with-openssl
    
  2. Install pycurl with correct build-time environment and paths

    export PYCURL_SSL_LIBRARY=openssl
    pip uninstall pycurl 
    pip install --no-cache-dir --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" --user pycurl
    
查看更多
冷血范
3楼-- · 2019-01-13 03:19

Following worked for me with Python3.6

MacOS High-Sierra

sudo pip3 uninstall pycurl
sudo pip3 install --compile --install-option="--with-openssl" pycurl 

CentOS 7

sudo pip3 uninstall pycurl
sudo pip3 install --compile --install-option="--with-nss" pycurl
查看更多
成全新的幸福
4楼-- · 2019-01-13 03:20

With OSX 10.13, a brew-installed openSSL, and virtualenv, I was successful with:

workon ..your-environment-here..
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib;export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir
查看更多
太酷不给撩
5楼-- · 2019-01-13 03:24

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 with your link-time ssl backend (which is openssl above)

    export PYCURL_SSL_LIBRARY=openssl

  • then, re-install pycurl

    pip install pycurl

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

查看更多
迷人小祖宗
6楼-- · 2019-01-13 03:24

You can download the tar.gz file from here. Then extract it into a folder. You'll find a setup.py file there. Run the command over there that the site mentioned. For example:

python setup.py --with-[ssl|gnutls|nss] install

FYI: I tried to install pycurl at my windows, but I couldn't. But did it on my linux.

查看更多
来,给爷笑一个
7楼-- · 2019-01-13 03:24
pip install -U pip

if [ "$(curl --version | grep NSS 2>/dev/null)" ]; then
    pip install --compile --install-option="--with-nss" pycurl
else
    pip install --compile --install-option="--with-openssl" pycurl
fi
查看更多
登录 后发表回答