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

8

25

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

Bailey answered 19/12, 2017 at 14:7 Comment(0)
D
38

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
Doublure answered 19/12, 2017 at 14:13 Comment(7)
Thank you for your kindness!! FInally I could make it!Bailey
running brew reinstall openssl was required on an upgraded macOS 10.13 machinePrussianism
how the heck did you know this solution (compile with ssl)? Thx!Moritz
+1, thanks. Anyone have any idea how I can install with poetry? poetry add pycurl doesn't seem to give the option of supplying flags.Riobard
On a macOS 12.3, after brew reinstall openssl you can run brew info openssl and it will tell you some environment variables you need to set for the pycurl install to work.Cybil
I had to find the path to openssl via brew info openssl and pass it to pip: pip install --compile --install-option="--with-openssl" --install-option="--openssl-dir=/opt/homebrew/opt/openssl@3/" pycurlSudanic
On a mac M1 with a recent version of pip, I used the following successfully: pip install --compile --config-settings="--build-option=--with-openssl --openssl-dir=/opt/homebrew/opt/openssl@3/" pycurl Quennie
F
16

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! enter image description here

Fiduciary answered 6/10, 2021 at 8:1 Comment(2)
This fix worked for me. The flags needed to be specified on OSX MontareyHistorical
Accepted answer did not work for me. This one did!Riobard
A
11

How I resolve this issue on my Mac Book Pro M1 (Chip Apple M1 Pro).

I am using system provided Python 3.9.6 as MacOs Monterey 12.6 completely removed Python 2.7 and providing Python 3.9.6 as system Python.

two thing is very important to know curl info by using

  1. curl-config --features
  2. brew openssl info

this gives you information according to your own machine setup for using in below installation to use.

In my case it was

export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"

For pkg-config to find openssl@3 you may need to set:

export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl

it was done!!! perfectly.

Alternatively, if you get an error saying

no such option: --install-option

You can try:

env PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" pip install --no-cache-dir --compile --ignore-installed pycurl

and it should work!

Aretta answered 23/10, 2022 at 17:29 Comment(0)
D
8

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
Dialytic answered 30/1, 2022 at 13:4 Comment(2)
I had to add --use-pep517 in addition: pip install --no-cache-dir --ignore-installed --compile --install-option="--with-openssl" pycurl --use-pep517Undersecretary
--install-option is not an option for later versions of pipBipartite
C
7

Setup: MacOS Ventura, M1, Python 3.9, pip 23.1.2

With pip 23.1, --install-option="..." is deprecated.

What worked for me was actually following the installation guide from pycurl: http://pycurl.io/docs/latest/install.html#easy-install-pip

pip3 uninstall pycurl  
brew install curl-openssl
export PYCURL_SSL_LIBRARY=openssl
pip3 install --no-cache-dir --ignore-installed --compile pycurl
Capitalism answered 7/7, 2023 at 8:46 Comment(0)
I
2

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
Icterus answered 11/5, 2018 at 13:38 Comment(1)
Error: invalid option: --with-opensslDilapidate
P
0

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
Popish answered 18/9, 2020 at 17:13 Comment(2)
This works for me, but for my case, the install command requires one more flag: ARCHFLAGS="-arch x86_64" pip install pycurl --compile --no-cache-dirTice
For me on BigSur (11.2.3) with a M1: export PYCURL_SSL_LIBRARY=openssl export PYCURL_CURL_CONFIG=/opt/homebrew/opt/curl/bin/curl-config export LDFLAGS='-L/opt/homebrew/opt/openssl/lib/' export CPPFLAGS=-I/opt/homebrew/opt/openssl/include pip install pycurl --compile --no-cache-dir Reneareneau
U
0

I am running MacOS Ventura on my MacBook Pro. We use Python 3.7. The following worked for me:

% python3.7 -m pip uninstall pycurl
% brew install curl
% brew install openssl

% export LDFLAGS="-L/usr/local/opt/curl/lib $LDFLAGS"
% export CPPFLAGS="-I/usr/local/opt/curl/include $CPPFLAGS"
% export PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig

% python3.7 -m pip install pycurl==7.45.2 --no-cache-dir --compile --ignore-installed --install-option="--openssl-dir=/usr/local/opt/openssl@3/"
Undergrowth answered 20/12, 2022 at 18:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.