我将 Mac 从 High Sierra 升级到 Catalina,但系统崩溃了import pycurl
。请参阅下面的错误。
我尝试了所有用户声称成功的选项Stack Overflow 帖子但无济于事。
ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)
我的 pycurl 版本是7.43.0.3
Python 版本是3.6.4。
[我也尝试了 Catalina 的 1.0.2t,然后尝试了libressl
下面的方法]
% openssl version -a
LibreSSL 2.8.3
built on: date not available
platform: information not available
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"
% echo $PYCURL_SSL_LIBRARY
openssl
% echo $LDFLAGS
-L/usr/local/opt/openssl/lib
% echo $CPPFLAGS
-I/usr/local/opt/openssl/include
我尝试了上述所有命令的组合:
% pip install --global-option="--with-openssl" --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include --compile --no-cache-dir" pycurl
% brew uninstall openssl
ETC。
我使用了 easy_install。
但它刚刚破损卡塔利娜!!有谁解决了这个问题吗?
答案1
下面的办法对我有用,尽管它看起来有点奇怪。也许可以一直用下去,直到出现更好的解决方案?
brew install curl-openssl
export PYCURL_SSL_LIBRARY=openssl
export PYCURL_CURL_CONFIG=/usr/local/opt/curl-openssl/bin/curl-config
export LDFLAGS='-L/usr/local/opt/openssl/lib -L/usr/local/opt/c-ares/lib -L/usr/local/opt/nghttp2/lib -L/usr/local/opt/libmetalink/lib -L/usr/local/opt/rtmpdump/lib -L/usr/local/opt/libssh2/lib -L/usr/local/opt/openldap/lib -L/usr/local/opt/brotli/lib'
export CPPFLAGS=-I/usr/local/opt/openssl/include
pip install pycurl --compile --no-cache-dir
macOS 10.15 Python 3.7.4 pycurl 7.43.0.3 OpenSSL 1.0.2t
答案2
这对我有用
pip uninstall pycurl
pip install --compile --install-option="--with-openssl" pycurl
答案3
我在 MacBook Pro 上运行 MacOS ventura。我们使用 Ptyhon 3.7。以下方法对我有用:
% python3.7 -m pip uninstall pycurl
% brew install curl
% brew install openssl
% export LDFLAGS="-L/usr/local/opt/curl/lib $LDFLAGS"
% export CPPFLAGS="-I/usr/local/opt/curl/include $CPPFLAGS"
% export PKG_CONFIG_PATH=/usr/local/opt/curl/lib/pkgconfig
% python3.7 -m pip install pycurl==7.45.2 --no-cache-dir --compile --ignore-installed --install-option="--openssl-dir=/usr/local/opt/openssl@3/"