SSL backend error when using OpenSSL

前端 未结 26 2375
北恋
北恋 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条回答
  • FWIW, I ran into a lot of issues getting this working via AWS Elastic Beanstalk and finally was able to get it working with:

    packages:
      yum:
        openssl-devel: []
        libcurl-devel: []
    
    container_commands:
      # Reinstall PyCurl with correct ssl backend
      05_reinstall_pycurl:
        command: |
          pip install --upgrade pip
          pip uninstall -y pycurl
          pip install --global-option='--with-openssl' pycurl
    
    0 讨论(0)
  • 2020-11-30 23:17

    This worked for me:

    pip uninstall pycurl
    export PYCURL_SSL_LIBRARY=nss
    easy_install pycurl
    

    None of this worked for me (note the difference is simply easy_install vs pip):

    pip uninstall pycurl
    export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
    pip install pycurl
    #xor
    curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.1.tar.gz
    #...
    python setup.py --with-[nss|openssl|ssl|gnutls] install
    
    0 讨论(0)
  • 2020-11-30 23:18

    I am running this on OS X and some of the above solutions weren't working. Similar to Edward Newell's comment the PYCURL_SSL_LIBRARY variable seemed to have been completely ignored.
    Further reading of the PycURL installation doc revealed the following:

    pip may reinstall the package it has previously compiled instead of recompiling pycurl with newly specified options

    Therefore, I had to force it to compile with:

    pip install --compile pycurl

    That works on a number of cases. However, I did run into a few systems that continued to ignore the variable so, similar to maharg101's answer, I resorted to the install options which through pip can be set like this:

    pip install pycurl --global-option="--with-[ssl|gnutls|nss]"

    where you select one of the three options inside the square brackets. Notice that the available option is ssl and not openssl. If you specify --with-openssl you'll get an error. Also note that if you were messing around with the PYCURL_SSL_LIBRARY variable and switching it to funky values to see what would happen this last command will definitely catch it and throw an error if the value is set but not valid.

    0 讨论(0)
  • 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'

    0 讨论(0)
  • 2020-11-30 23:19

    helloworld2013's answer is correct, but the key is matching the SSL library that pycurl is expecting. The error will be something like:

    pycurl: libcurl link-time ssl backend (<library>) is different from compile-time ssl backend (<library> or "none/other")

    To fix it, you have to use the library pycurl is expecting. In my case, my error was "pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)", so my fix was:

    pip uninstall pycurl
    export PYCURL_SSL_LIBRARY=nss
    pip install pycurl
    
    0 讨论(0)
  • 2020-11-30 23:20

    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
    
    0 讨论(0)
提交回复
热议问题