Pycurl底层使用libcurl,请先确定Libcurl是否已支持异步DNS解析c-ares,如不支持可升级libcurl支持异步DNS解析c-ares。
其实Libcurl更新支持为异步DNS如果已安装pycurl不用重新安装Pycurl,见https://www.haiyun.me/archives/1070.html
通过pip安装:
export PATH=/usr/local/curl/bin/:$PATH
export LD_LIBRARY_PATH="/usr/local/curl/lib/"
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl
下载pycurl源码包安装:
wget http://pycurl.sourceforge.net/download/pycurl-7.19.5.1.tar.gz
tar zxvf pycurl-7.19.5.1.tar.gz
cd pycurl-7.19.5.1
export LD_LIBRARY_PATH="/usr/local/curl/lib/"
python setup.py install --curl-config=/usr/local/curl/bin/curl-config --with-ssl
检查pycurl是否已支持异步DNS解析c-ares:
>>> import pycurl
>>> pycurl.version
'PycURL/7.19.5.1 libcurl/7.40.0 OpenSSL/1.0.1e zlib/1.2.7 c-ares/1.10.0'
安装pycurl后使用时遇到的一些错误:
pycurl.so: undefined symbol: CRYPTO_num_locks
原因:libcurl安装时--with-ssl支持
libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
原因:libcurl和pycurl编译时ssl后端不一致,调整见上和libcurl安装
pycurl: libcurl link-time version (7.19.7) is older than compile-time version (7.4.0)
原因:编译pycurl时使用的编译的libcurl动态库,不过现在pycurl现在加载的是系统自带的版本较旧的动态库,解决将编译的libcurl动态库添加到系统动态库,见ldconfig