如何在Apple M1芯片设备上使用pip v23.1+安装pycurl?
在Apple M1芯片Mac上使用pip v23.1+安装pycurl(搭配OpenSSL 3)
由于pip v23.1+移除了--install-option参数,原有的pycurl安装命令已失效,可通过设置环境变量替代原参数的作用,具体步骤如下:
首先更新brew并安装OpenSSL 3:
brew update && brew install openssl@3设置编译相关环境变量,同时指定pycurl使用的SSL库:
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" export PYCURL_SSL_LIBRARY=opensslPYCURL_SSL_LIBRARY是pycurl官方支持的环境变量,用于指定依赖的SSL库,替代原--with-openssl安装选项卸载已安装的pycurl(若存在):
pip uninstall -y pycurl编译并安装pycurl:
pip install --compile pycurl
验证安装结果
安装完成后,可通过以下Python代码验证是否成功关联OpenSSL 3:
import pycurl c = pycurl.Curl() print(c.getinfo(pycurl.SSL_VERSION))
输出内容应包含OpenSSL 3的版本信息。
内容的提问来源于stack exchange,提问作者jdesilvio
相关产品推荐
相关产品推荐

