问题
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.
回答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.)
回答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!
回答3:
For Ubuntu 18.04
conda install pycurl
回答4:
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
来源:https://stackoverflow.com/questions/37812070/mac-os-importerror-pycurl-libcurl-link-time-version-7-37-1-is-older-than-com