ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
我阅读了一些文档,其中提到:“要解决这个问题,你需要告诉setup.py使用哪个SSL后端”(来源),但是我不确定该如何做,因为我是使用pip安装的pycurl。
请问我如何在使用pip安装pycurl时指定SSL后端呢?
谢谢。
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
我阅读了一些文档,其中提到:“要解决这个问题,你需要告诉setup.py使用哪个SSL后端”(来源),但是我不确定该如何做,因为我是使用pip安装的pycurl。
请问我如何在使用pip安装pycurl时指定SSL后端呢?
谢谢。
阅读安装文件后,我通过设置环境变量并重新安装解决了我的问题。
# remove existing `pycurl` installation
pip uninstall pycurl
# export variable with your link-time ssl backend (which is openssl above)
export PYCURL_SSL_LIBRARY=openssl
# then, re-install `pycurl` with **no cache**
pip install pycurl --no-cache-dir
可能有其他解决方案,但这对于我在virtualenv
和pip
安装上完美地运作。
nss
而不是openssl
ImportError: pycurl:libcurl链接时ssl后端(nss)
(关键部分是nss
),所以您必须针对此错误消息执行某些操作:
pip uninstall pycurl
pip install --no-cache-dir --compile --compile-options="--with-nss" pycurl
PYCURL_SSL_LIBRARY=openssl
完美地运行了! - thneeset -x PYCURL_SSL_LIBRARY openssl
而不是export PYCURL_SSL_LIBRARY=openssl
。 - Sergeexport PYCURL_SSL_LIBRARY=nss
,因为这是我系统上安装的内容。 - caramhelloworld2013的回答是正确的,但关键在于匹配pycurl所期望的SSL库。错误信息可能如下所示:
pycurl: libcurl链接时的SSL后端(<library>)与编译时的SSL后端(<library>或“none/other”)不同
要修复它,您必须使用pycurl期望的库。在我的情况下,我的错误是“pycurl: libcurl链接时的SSL后端(nss)与编译时的SSL后端(openssl)不同”,所以我的解决方法是:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
pip install pycurl
PYCURL_SSL_LIBRARY
完全被忽略了。 对于我来说,编译时的 SSL 后端始终为“(none/other)”,尽管 echo PYCURL_SSL_LIBRARY
显示的是 openssl
。 - Edward Newellpycurl
并使用以下标记进行安装: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" pycurl
。 - eigeneinpip install pycurl --compile --no-cache-dir
。 - Robert Yi使用macOS 10.13,brew安装的openSSL和virtualenv,我成功地完成了以下操作:
# cd to your virtualenv, then…
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
pip install pycurl --compile --no-cache-dir
import pycurl
,结果出现了以下错误:ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)
。 - Daryl Spitzer使用pip 7.1,您可以将以下内容放入要求文件中:
pycurl==7.19.5.1 --global-option="--with-nss"
只需将 nss 替换为相应的 SSL 后端库。
Mac OS High Sierra更新后修复pycurl的方法:
重新安装curl库以使用OpenSSL而不是SecureTransport
brew install curl --with-openssl
使用正确的构建环境和路径安装pycurl
export PYCURL_SSL_LIBRARY=openssl
pip uninstall pycurl
pip install --no-cache-dir --global-option=build_ext --global-option="-L/usr/local/opt/openssl/lib" --global-option="-I/usr/local/opt/openssl/include" --user pycurl
--user
的情况下执行上述操作后,似乎成功安装了。但是当我执行import pycurl
时,出现了以下错误:ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)
。 - Daryl Spitzer这对我起作用了:
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=nss
easy_install pycurl
对我来说,这些都没用(请注意区别只是easy_install和pip):
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
pip install pycurl
#xor
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.1.tar.gz
#...
python setup.py --with-[nss|openssl|ssl|gnutls] install
ImportError: pycurl: libcurl link-time ssl backend (openssl) is different from compile-time ssl backend (none/other)
时,这个方法对我有用。 - James McCormac我遇到了这个问题好几天。最终,在其他答案的帮助下(主要是Alexander Tyapkov的),我让它在AWS Elastic Beanstalk上工作。
手动安装(通过SSH连接):
sudo pip uninstall pycurl
curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
sudo pip install pycurl-7.43.0.tar.gz --global-option="--with-nss"
重要提示: 请注意确保您使用的是正确版本的Python和PIP,否则可能会将其编译为Python 2.x并使用v3.x。
Elastic Beanstalk中的自动安装:
files:
"/usr/local/share/pycurl-7.43.0.tar.gz" :
mode: "000644"
owner: root
group: root
source: https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz
commands:
01_download_pip3:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'curl -O https://bootstrap.pypa.io/get-pip.py'
02_install_pip3:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'python3 get-pip.py'
03_pycurl_uninstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: '/usr/bin/yes | sudo pip uninstall pycurl'
04_pycurl_download:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'curl -O https://pypi.python.org/packages/source/p/pycurl/pycurl-7.43.0.tar.gz'
05_pycurl_reinstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
command: 'sudo pip install pycurl-7.43.0.tar.gz --global-option="--with-nss"'
container_commands:
09_pycurl_reinstall:
# run this before PIP installs requirements as it needs to be compiled with OpenSSL
# the upgrade option is because it will run after PIP installs the requirements.txt file.
# and it needs to be done with the virtual-env activated
command: 'source /opt/python/run/venv/bin/activate && pip3 install /usr/local/share/pycurl-7.43.0.tar.gz --global-option="--with-nss" --upgrade'
我遇到这个问题是因为我正在尝试在Elastic Beanstalk中使用Celery 4配置Django 1.10。 如果你也遇到了同样的问题,我写了一篇关于此的完整博客文章。
我使用的是CentOS 7操作系统。我尝试了以上所有方法,但都没有成功。最终发现需要以root用户身份运行这些命令。如果你也遇到了问题,可以尝试使用以上任何一种解决方法并以root用户身份运行。以下是我成功运行的示例:
su -
pip uninstall pycurl
export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls]
pip install pycurl
python setup.py --with-[ssl|gnutls|nss] install
提供信息:我尝试在Windows上安装pycurl,但失败了。但是在我的Linux上成功了。
我在OS X上运行此程序,其中一些解决方案不起作用。与Edward Newell's comment类似,PYCURL_SSL_LIBRARY
变量似乎被完全忽略了。
进一步阅读PycURL installation doc发现以下内容:
pip可能会重新安装它先前编译过的软件包,而不是使用新指定的选项重新编译pycurl。
因此,我必须强制使用以下命令进行编译:
pip install --compile pycurl
这适用于许多情况。但是,我遇到了一些系统仍然忽略该变量,所以类似于maharg101's answer,我采用了通过pip设置的安装选项:
pip install pycurl --global-option="--with-[ssl|gnutls|nss]"
在方括号内选择三个选项之一。请注意,可用选项为ssl
而不是openssl
。如果指定--with-openssl
,则会出现错误。还要注意,如果您正在与PYCURL_SSL_LIBRARY
变量玩弄,并将其切换为奇怪的值以查看会发生什么,那么此命令肯定会捕获它并在设置但无效时抛出错误。
pip install pycurl --global-option="--with-nss"
即可。值得一提的是,我的错误信息是ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (openssl)
。 - ahyong