'MAC OS ImportError: pycurl: libcurl link-time version (7.37.1) is older than compile-time version (7.43.0)

when i import curl in python interface,it displayed the error

ImportError: pycurl: libcurl link-time version (7.37.1) is older than compile-time version (7.43.0).

how to solve it ? my system is yosemite.



Solution 1:[1]

I met this error on Sierra. Thanks to seeliuh's post in this issue, I fixed it after doing:

1.uninstall pycurl.

pip uninstall pycurl

2.export LD_LIBRARY_PATH=<<your homebrew's libcurl path>>

export LD_LIBRARY_PATH=/usr/local/opt/curl/lib

export LIBRARY_PATH=/usr/local/opt/curl/lib

3.reinstall pycurl

easy_install pycurl # you also can try to use pip though using it here probably would cause some problems

Note:

PycURL documentation points out that:

If libcurl is linked dynamically with pycurl, you may have to alter the LD_LIBRARY_PATH environment variable accordingly. This normally applies only if there is more than one version of libcurl installed, e.g. one in /usr/lib and one in /usr/local/lib.

So, you should change your LD_LIBRARY_PATH into your homebrew's libcurl path. (The version of your homebrew's libcurl is supposed to be larger than the compile-time version. Please check that.)

Solution 2:[2]

Okay, since this answer still pops up in the Google Search, I'll share my workaround for fixing this issue.

Main idea to install brew version of curl and force linking to get an up-to-date curl:

$ curl --version
curl 7.52.1 (x86_64-apple-darwin16.1.0) libcurl/7.52.1 OpenSSL/1.0.2j zlib/1.2.8 nghttp2/1.18.1

So you can later use pycurl, linked against your libcurl and openssl

brew install curl
brew link curl --force
brew install openssl
export LIBRARY_PATH=/usr/local/opt/openssl/lib
export CPATH=/usr/local/opt/openssl/include
pip --no-cache-dir install pycurl
python -c "import pycurl"

Hope that helps!

Solution 3:[3]

I had the same issue on Ubuntu and couldn't get the other solutions to work so I ended up uninstalling curl and installing the newest version. If you go for this approach be careful not to uninstall any dependencies (I uninstalled VirtualBox together with curl by mistake). Then to install the correct version I used this guide: https://www.mysterydata.com/install-latest-curl-version-on-ubuntu-vestacp/. Also if you have Conda installed it might still be pointing to the wrong libcurl so might need to remove that too.

Solution 4:[4]

Face the same problem with Mac 11.6.5 and python 3.10

~ > pip install pycurl
~ > python -c 'import pycurl'
ImportError: pycurl: libcurl link-time version (7.64.1) is older than compile-time version (7.77.0)

I didn't manage to change link-time version (7.64.1), so I download exact version of linked curl-7.64.1 and use it for pycurl compilation.

# Remove installed version
pip uninstall -y pycurl
brew uninstall curl

# Install openssl for pycurl compiling
brew install openssl || brew update openssl

# Downloading sources
wget https://curl.haxx.se/download/curl-7.64.1.tar.bz2
tar -xf curl-7.64.1.tar.bz2

# Setting up compiler flags 
export LDFLAGS="-L$(pwd)/curl-7.64.1/lib -L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I$(pwd)/curl-7.64.1/include -I/usr/local/opt/openssl@3/include"

# Installing
pip install --no-cache-dir --compile --install-option="--with-openssl" pycurl

# Checking up 
python -c "import pycurl" && echo "Success!"

Solution 5:[5]

For Ubuntu 18.04

conda install pycurl

Solution 6:[6]

I'm on macOS Mojave and using conda virtual environment. I tried with pip, then with easy_install (which worked for many). Tried installing/uninstalling curl and so on. In the end, this simple solution worked (in your virtual environment), as George Carvalho suggested in the answer above:

pip uninstall pycurl 
conda install --name <YOUR ENVIRONMENT NAME> pycurl

The thing is that when installing with conda to conda virtual environment it updates all the dependencies properly. In my case installing with conda resulted in:

The following NEW packages will be INSTALLED:

  krb5               pkgs/main/osx-64::krb5-1.16.1-hddcf347_7
  libcurl            pkgs/main/osx-64::libcurl-7.63.0-h051b688_1000
  libssh2            pkgs/main/osx-64::libssh2-1.8.0-ha12b0ac_4
  pycurl             pkgs/main/osx-64::pycurl-7.43.0.2-py37ha12b0ac_0

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
Solution 2 beyondfloatingpoint
Solution 3 Szymon Palucha
Solution 4
Solution 5 George Carvalho
Solution 6 SuperCatman