SSL backend error when using OpenSSL

前端 未结 26 2551
北恋
北恋 2020-11-30 22:38

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         


        
26条回答
  •  既然无缘
    2020-11-30 23:18

    Reinstallation of curl

    I tried every suggestion from this discussion but no one worked for me. As solution I have reinstalled curl and curlib. After that I was able to install pycurl with ssl support inside environment.

    At start:

    'PycURL/7.43.0 libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3'

    Part 1.Re/Installation with pip

    Firstly I have removed pycurl from virtualenv using pip as was suggested previous answers:

    pip uninstall pycurl
    export PYCURL_SSL_LIBRARY=openssl
    pip install pycurl --global-option="--with-openssl"
    

    The idea here is that package was cached and we just reintstall it with openssl option.

    I also tried to recompile pycurl with pip using:

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

    ..but had the same error after running:

    python
    import pycurl
    pycurl.version
    

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

    Part 2. Installation from tar

    After previous method didn't work I have decidede to install pycurl from tar with:

    curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
    sudo tar -xzvf pycurl-7.43.0.tar.gz
    cd pycurl-7.43.0/
    sudo python setup.py --with-ssl install
    

    It has installed pycurl globally but not within virtualenv. I also didn't check if it was installed with SSL support or not but think that still without ssl.

    Part 3. Reinstallation of curl and curllib

    Finally I understood that pycurl doesn't installs normally into environment because global curl and libcurl are compiled with gnutls.

    Before starting check it with:

    curl-config --configure
    

    One of the output lines will be

    '--without-ssl' '--with-gnutls'

    To recompile it:

    Firstly remove curl:

    sudo apt-get purge curl
    

    Install any build dependencies needed for curl

    sudo apt-get build-dep curl
    

    Get latest (as of Dec 20, 2016) libcurl

    mkdir ~/curl
    wget http://curl.haxx.se/download/curl-7.51.0.tar.bz2
    tar -xvjf curl-7.51.0.tar.bz2
    cd curl-7.51.0
    

    The usual steps for building an app from source

    ./configure
    ./make
     sudo make install
    

    If openssl installed correctly then configure will find it automatically. The output will be:

    curl version: 7.51.0
    Host setup: x86_64-pc-linux-gnu
    Install prefix: /usr/local
    Compiler: gcc
    SSL support: enabled (OpenSSL) ...

    Resolve any issues of C-level lib location caches ("shared library cache")

    sudo ldconfig
    

    Now try to reinstall pycurl within environment:

    curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
    pip install pycurl-7.43.0.tar.gz --global-option="--with-openssl"
    

    The result should be:

    python
    import pycurl
    pycurl.version
    

    'PycURL/7.43.0 libcurl/7.51.0 OpenSSL/1.0.2g zlib/1.2.8 librtmp/2.3'

提交回复
热议问题