我试图使用pip在virtualenv中安装pycurl,我收到了这个错误
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后端?
谢谢
在阅读了他们的INSTALLATION文件后,我能够通过设置环境变量并重新安装来解决我的问题
删除现有pycurl
安装
pip uninstall pycurl
使用链接时ssl后端导出变量(上面是openssl)
export PYCURL_SSL_LIBRARY=openssl
然后,重新安装 pycurl
pip install pycurl --no-cache-dir
可能有其他的解决方案在那里,但这个工程完美的我在virtualenv
和pip
安装.
helloworld2013的答案是正确的,但关键是匹配pycurl期望的SSL库.错误将是这样的:
pycurl:libcurl link-time ssl后端(<library>)与编译时ssl后端(<library>或" none/other ")不同
要修复它,你必须使用pycurl所期望的库.在我的情况下,我的错误是" pycurl:libcurl link-time ssl backend(nss)与编译时ssl后端(openssl)不同 ",所以我的修复是:
pip uninstall pycurl export PYCURL_SSL_LIBRARY=nss pip install pycurl
使用pip 7.1,您可以将以下内容放入需求文件中:
pycurl==7.19.5.1 --global-option="--with-nss"
只需用相关的ssl后端库替换nss即可.
这对我有用:
pip uninstall pycurl export PYCURL_SSL_LIBRARY=nss easy_install pycurl
这些对我都没有用(注意区别就是easy_install vs 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
我在CentOS 7上.我尝试了以上所有内容并且无法正常工作.事实证明我需要以root用户身份运行它们.因此,如果您遇到问题,请以root用户身份尝试上述任何解决方案.举个例子,这对我有用:
su - pip uninstall pycurl export PYCURL_SSL_LIBRARY=[nss|openssl|ssl|gnutls] pip install pycurl
当然,所有关于以root用户身份运行的免责声明均适用.
注意:上面代码中的[nss | openssl | ssl | gnutls]表示选择一个,不包括方括号或管道.问原问题的人会选择openssl.在我的特殊情况下,我选择了nss.您的错误消息应该告诉您要做出哪个选择.
在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
您可以从这里下载tar.gz文件.然后将其提取到一个文件夹中.你会在那里找到一个setup.py文件.运行该站点提到的命令.例如:
python setup.py --with-[ssl|gnutls|nss] install
仅供参考:我试图在我的窗户安装pycurl,但我不能.但是在我的linux上做了.
我好几天都有这个问题.最后在这里的其他答案的帮助下(主要是亚历山大·泰普科夫),我得到了它为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中使用Django 1.10配置Celery 4.如果那是你的情况,我写了一篇关于它的完整博客文章.
使用OSX 10.13,brew安装的openSSL和virtualenv,我成功地:
workon ..your-environment-here.. 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