【问题标题】:Failed pycurl install on macos using pip使用 pip 在 macOS 上安装 pycurl 失败
【发布时间】:2018-10-26 15:30:53
【问题描述】:

我希望有人可以提供帮助。 我目前正在我的 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 后端问题是我认为的首要问题

【问题讨论】:

标签: python macos pip pycurl


【解决方案1】:

似乎Apple stopped including OpenSSL headers 从 OS X 10.11 El Capitan 开始。

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

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。
希望这会有所帮助。

【讨论】:

  • /opt/local/ MacPorts 安装
  • 感谢 Anil_M 的详细评论,但我仍然收到相同的错误 Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/ky/wl4zf4wd60ngypxp5kcmy9vm00012d/T/pip -install-ztPG_j/pycurl/