我想运行python文件。但是当我运行它时我可以检查这个错误。
导入错误:pycurl:libcurl 链接时 ssl 后端(openssl)与编译时 ssl 后端(无/其他)不同
我的系统是 Mac os 10.13.2,我使用的是 python 2.7
Blu*_*uds 16
这是我的 mac 用户朋友完成的。
# pycurl
pip uninstall pycurl
export CPPFLAGS=-I/usr/local/opt/openssl/include # may be needed
export LDFLAGS=-L/usr/local/opt/openssl/lib # may be needed
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
Run Code Online (Sandbox Code Playgroud)
我在 Windows 中遇到了同样的问题,但有不同的修复(也许这也适合 Mac)。在我的requirements.txt中,我有pycurl-7.43.0.4,但在Windows下载器页面上我只能找到7.44.1我安装的(pip install .\pycurl-7.44.1-cp37-cp37m-win_amd64.whl)。然后在启动 Django 服务器时python manage.py runserver我收到了相关错误。解决方案是将 pycurl 恢复到预期版本。pip install pycurl==7.43.0.5它取代了如下所示的版本。错误消失了!

Eyt*_*ror 15
pycurl/openssl 好像出了点问题,试试这个:
pip uninstall pycurl
pip install --compile --install-option="--with-openssl" pycurl
Run Code Online (Sandbox Code Playgroud)
如果仍然失败,也试试这个
brew reinstall openssl
Run Code Online (Sandbox Code Playgroud)
小智 11
如何在 Mac Book Pro M1(芯片 Apple M1 Pro)上解决此问题。
我使用系统提供的Python 3.9.6作为MacOs Monterey 12.6完全删除了Python 2.7并提供Python 3.9.6作为系统Python。
通过使用了解curl信息有两件事非常重要
curl-config --featuresbrew openssl info这会根据您自己的计算机设置为您提供信息,以便在下面的安装中使用。
就我而言是
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
Run Code Online (Sandbox Code Playgroud)
为了让 pkg-config 找到 openssl@3,您可能需要设置:
export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
Run Code Online (Sandbox Code Playgroud)
pip install --no-cache-dir --compile --ignore-installed --install-option="--with-openssl" pycurl
Run Code Online (Sandbox Code Playgroud)
完成了!完美。
或者,如果您收到错误消息
no such option: --install-option
Run Code Online (Sandbox Code Playgroud)
你可以试试:
env PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib" CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include" pip install --no-cache-dir --compile --ignore-installed pycurl
Run Code Online (Sandbox Code Playgroud)
它应该有效!
小智 8
对于 m1 用户,它对我有用
brew install curl-openssl
pip uninstall pycurl
PYCURL_SSL_LIBRARY=openssl \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
CPPFLAGS="-I$(brew --prefix openssl)/include"
pip install --compile --install-option="--with-openssl" pycurl
Run Code Online (Sandbox Code Playgroud)
小智 7
设置:MacOS Ventura、M1、Python 3.9、pip 23.1.2
在 pip 23.1 中,--install-option="..."已弃用。
对我有用的实际上是遵循 pycurl 的安装指南:http://pycurl.io/docs/latest/install.html#easy-install-pip
pip3 uninstall pycurl
brew install curl-openssl
export PYCURL_SSL_LIBRARY=openssl
pip3 install --no-cache-dir --ignore-installed --compile pycurl
Run Code Online (Sandbox Code Playgroud)