python3安装pycurl

centos7安装pycurl

出现错误

FileNotFoundError: [Errno 2] No such file or directory: 'curl-config'
ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)
https://github.com/pycurl/pycurl/pull/353

安装包解决办法:
重新安装以下的库
centos

yum install libcurl-devel

由于libcurl的源码编译因素,在安装pycurl可能会导致以下两种错误。

错误1:

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

错误2:

ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)

解决办法:

错误1的解决办法如下:

pip uninstall pycurl

export PYCURL_SSL_LIBRARY=openssl

pip install pycurl

错误2的解决办法如下:

pip uninstall pycurl

export PYCURL_SSL_LIBRARY=nss

pip install pycurl

结果

Installing collected packages: pycurl
  Running setup.py install for pycurl ... done
Successfully installed pycurl-7.43.0.1

源码解决办法

wget http://curl.haxx.se/download/curl-7.24.0.tar.gz
tar -zxvf curl-7.24.0.tar.gz
cd curl-7.24.0
./configure
make && make install

安装pycurl,使用--curl-config=制定curl-config的路径

wget https://dl.bintray.com/pycurl/pycurl/pycurl-7.43.0.1.tar.gz
tar -xzvf pycurl-7.43.0.1.tar.gz
cd pycurl-7.43.0.1
python3 setup.py --with-openssl install --curl-config=/usr/local/bin/curl-config

结果

Using /usr/local/bin/curl-config (libcurl 7.24.0)
running install
running build
running build_py
creating build
......
Writing /usr/local/python3/lib/python3.6/site-packages/pycurl-7.43.0.1-py3.6.egg-info

安装成功

原文地址:https://www.cnblogs.com/52py/p/9481229.html