'ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
I wanted to run python file. But I could check this error when I ran it.
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
My system is Mac os 10.13.2 and I used python 2.7
Solution 1:[1]
Looks like something went wrong with pycurl/openssl, try this:
pip uninstall pycurl
pip install --compile --install-option="--with-openssl" pycurl
if still fails, try this as well
brew reinstall openssl
Solution 2:[2]
This was done by my fellow mac users.
# pycurl
pip uninstall pycurl
export CPPFLAGS=-I/usr/local/opt/openssl/include # may be needed
export LDFLAGS=-L/usr/local/opt/openssl/lib # may be needed
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
I got this same issue in windows which had a different fix(perhaps this might fit Mac too). In my requirements.txt I had pycurl-7.43.0.4 but on the windows dowloader page I could only find 7.44.1 which I installed (pip install .\pycurl-7.44.1-cp37-cp37m-win_amd64.whl). And then on starting my Django server python manage.py runserver I got the error in question. And the solution was to bring the pycurl back to it's expected version. pip install pycurl==7.43.0.5 and it replaced the version as given below. And the error was gone!

Solution 3:[3]
For m1 users, it works for me
brew install curl-openssl
pip uninstall pycurl
PYCURL_SSL_LIBRARY=openssl \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
CPPFLAGS="-I$(brew --prefix openssl)/include"
pip install --compile --install-option="--with-openssl" pycurl
Solution 4:[4]
Reinstall the curl libraries
brew install curl --with-openssl
Install pycurl with correct 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" pycurl
Solution 5:[5]
On macOS Catalina (v10.15.6), make sure you uninstall previous curl then install curl-openssl as well as exporting variables so compiler can find them:
brew uninstall curl
brew install curl-openssl
export PYCURL_SSL_LIBRARY=openssl
export PYCURL_CURL_CONFIG=/usr/local/opt/curl-openssl/bin/curl-config;export LDFLAGS='-L/usr/local/opt/openssl/lib -L/usr/local/opt/c-ares/lib -L/usr/local/opt/nghttp2/lib -L/usr/local/opt/libmetalink/lib -L/usr/local/opt/rtmpdump/lib -L/usr/local/opt/libssh2/lib -L/usr/local/opt/openldap/lib -L/usr/local/opt/brotli/lib';export CPPFLAGS=-I/usr/local/opt/openssl/include;pip install pycurl --compile --no-cache-dir
pip install pycurl
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Eytan Avisror |
| Solution 2 | |
| Solution 3 | Jacob kshin |
| Solution 4 | Ruslan |
| Solution 5 | Andre Pereira |
