首页 > 解决方案 > 使用 pip 在 macOS 上安装 pycurl 失败

问题描述

我希望有人能帮帮忙。我目前正在我的 2015 MacBook Pro 上构建我的 python 环境,它在 Sierra 10.12.6 上运行。我偶然发现了许多下载模块的问题,以便运行我的脚本来自动化我的工作任务(例如自动化电子邮件等),但我已经设法克服了这些问题,但是,PyCurl 不允许我克服。

我使用的命令以及各种变体本质上是-

sudo pip install pycurl

它返回以下内容 -

Collecting pycurl
Downloading https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz (214kB)
100% |████████████████████████████████| 215kB 5.7MB/s
Complete output from command python setup.py egg_info:
Using curl-config (libcurl 7.54.0)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/private/tmp/pip-install-rSkgA_/pycurl/setup.py", line 913, in <module>
    ext = get_extension(sys.argv, split_extension_source=split_extension_source)
  File "/private/tmp/pip-install-rSkgA_/pycurl/setup.py", line 582, in get_extension
    ext_config = ExtensionConfiguration(argv)
  File "/private/tmp/pip-install-rSkgA_/pycurl/setup.py", line 99, in __init__
    self.configure()
  File "/private/tmp/pip-install-rSkgA_/pycurl/setup.py", line 316, in configure_unix
    specify the SSL backend manually.''')
__main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually.

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-install-rSkgA_/pycurl/

最后的错误真的难倒我和我团队中的开发人员,我真的希望有人能提供帮助,因为我已经用尽了我办公室的资源!

编辑:SSL 后端问题是我认为的首要问题

标签: pythonmacospippycurl

解决方案


自 OS X 10.11 El Capitan 以来, Apple似乎停止包含 OpenSSL 标头。

为了解决这个问题,让我们通过 Homebrew 安装 OpenSSL:
如果openssl未安装,如下所示。否则,如果 openssl你的 mac 上已经安装了,你可以跳过这个。

brew install openssl

您收到 ssl 后端错误。为了帮助pycurl找到 OpenSSL 标头,我们需要告诉 setup.py 使用哪个 SSL 后端以及在哪里可以找到 OpenSSL

注意:检查您的 mac 上的 openssl-dir 位置并根据需要进行更改。

pip uninstall pycurl
pip install --install-option="--with-openssl" --install-option="--openssl-dir=/usr/local/opt/openssl" pycurl

如果需要,请使用 sudo。
希望这可以帮助。


推荐阅读