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

7

5

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.

Archduke answered 14/6, 2016 at 12:29 Comment(3)
Are you opening the system version of python or a 3rd-party version? What is $PYTHONPATH set to?Twi
i use pyenv to manage my python , system version python 2.7 and 3rd-party python 3.5.Archduke
Well, after two days ,i got it well without doing anything...i'm confused...Archduke
R
7

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.)

Radley answered 24/2, 2017 at 1:12 Comment(0)
D
6

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 and PATH
export PATH="$(pwd)/curl-7.64.1/bin:$PATH"
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!"
Demonstrator answered 2/5, 2022 at 14:7 Comment(0)
W
3

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!

Weisburgh answered 18/1, 2017 at 11:59 Comment(1)
This solution DOES NOT work under MacOSX 10.11.6. The CURL shipped with the OS uses SecureTransport. It is not built with OpenSSL. Someone wrote a post here too about this: daniel.haxx.se/blog/tag/securetransportSialkot
I
1

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.

Ignatius answered 11/4, 2020 at 10:15 Comment(0)
B
0

For Ubuntu 18.04

conda install pycurl

Blanchette answered 20/10, 2018 at 3:17 Comment(1)
Thank you for this code snippet, which might provide some limited, immediate help. A proper explanation would greatly improve its long-term value by showing why this is a good solution to the problem, and would make it more useful to future readers with other, similar questions. Please edit your answer to add some explanation, including the assumptions you've made.Shaman
H
0

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
Harri answered 26/2, 2019 at 18:3 Comment(0)
E
0

In my case I had two curl versions 8.3.0 and 7.87.0 just did brew uninstall curl and then did curl --version it showed me 7.87.0 and python -c 'import pycurl' just worked :)

Ethelyn answered 29/9, 2023 at 19:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.