鍍金池/ 問答/Java  iOS  網(wǎng)絡安全/ mac導入pycurl出錯重裝后還是報錯

mac導入pycurl出錯重裝后還是報錯

使用 Python 2.7.10版本
openssl version
LibreSSL 2.2.7

導入pycurl的時候會報錯

In [1]: import pycurl
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-141165d68a5f> in <module>()
----> 1 import pycurl

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

安裝網(wǎng)上的方法

sudo pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss 或者 export PYCURL_SSL_LIBRARY=openssl
sudo pip install pycurl

后還是會報出同樣的錯誤 找了很久也沒解決難受啊=-=

回答
編輯回答
旖襯

用homebrew安裝的OpenSSL,我這樣解決的

pip install pycurl==7.43.0.1 --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include"
2018年5月28日 10:36
編輯回答
墨小羽
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)

這個問題是可以用重新安裝解決

pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl

但是這里有一個坑:在高版本的mac系統(tǒng)環(huán)境變量里是找不到openssl的頭文件的

pip uninstall pycurl# 卸載庫
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include# openssl相關頭文件路徑
pip install pycurl --compile --no-cache-dir# 重新編譯安裝

環(huán)境信息:
Mac High Sierra 10.13.2
Python 3.6.0
pip 9.0.1
pycurl (7.43.0.1)

2017年10月11日 00:57