最好的方法,在ubuntu和centos上都可以安装.先安装anaconda3,然后使用命令:
conda install pycurl
--------------------------------------------------------------------------------------------------------------------------------------
在Ubuntu 16.04 18.04上安装pycurl时大致会遇到一下两个问题:
在使用pip install pycurl是报curl_config no found错误.
gnutls.h: No such file or directory
解决办法:
sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libghc-gnutls-dev
最后通过pip进行安装:
pip install pycurl
--------------------------------------------------------------------------------------------------------------------------------------
centos7
在centos7安装python3处处是坑,比如我安装了python3.6以后,在使用pycurl时会报错。
错误信息:ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)
遇到这个错误以后,我尝试了网上很多种方法解决但是都毫无效果,后来继续坚持试试,终于找到了一篇靠谱的文章,试了了一下完美解决
首先卸载掉原来安装的pycurl
pip uninstall pycurl
然后
wget http://curl.haxx.se/download/curl-7.36.0.tar.gz
wget https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.1.tar.gz
这里要先安装curl再安装pycurl
1,安装curl
tar -zxvf curl-7.36.0.tar.gz
cd curl-7.36.0/
./configure
make && make install
export LD_LIBRARY_PATH=/usr/local/lib #这一步至关重要,否则就会报上面所说的错误
意export,也就是说只能在当前终端有效,另开一个终端会失效
2,安装pycurl
tar -zxvf pycurl-7.19.3.1.tar.gz
cd pycurl-7.19.3.1
执行下面任意一条安装命令,如果报错就执行另一条
python setup.py install --curl=/usr/local/bin/curl
python setup.py install --curl-config=/usr/local/bin/curl-config
3,测试
Python 3.6.1 (default, Jun 6 2018, 06:30:51)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycurl
>>>