首页 > 解决方案 > pycurl macOS 安装问题

问题描述

我需要安装 pycurl 才能运行 python 脚本,但我找不到在 macOS 上执行此操作的方法。

我已经尝试过 brew,更新 Pip,但是在“pip install pycurl”之后我总是收到这个错误

Collecting pycurl
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
    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/var/folders/vk/f193293d0pvd2ynlcpnyx9100000gn/T/pip-install-rxidIQ/pycurl/setup.py", line 913, in <module>
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/private/var/folders/vk/f193293d0pvd2ynlcpnyx9100000gn/T/pip-install-rxidIQ/pycurl/setup.py", line 582, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/private/var/folders/vk/f193293d0pvd2ynlcpnyx9100000gn/T/pip-install-rxidIQ/pycurl/setup.py", line 99, in __init__
        self.configure()
      File "/private/var/folders/vk/f193293d0pvd2ynlcpnyx9100000gn/T/pip-install-rxidIQ/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.

有什么建议吗?

标签: macosinstallationpycurl

解决方案


最新版本的 curl 支持多个 ssl 后端,而 pycurl 无法确定在安装期间使用哪一个。这是 7.43.0.2 中的一个已知问题 ( https://github.com/pycurl/pycurl/issues/530 )。很多人说安装 curl 支持 openssl,但在 macos 上最好使用默认的 SecureTransport 并让系统访问钥匙串,而不是使用 openssl 中捆绑的证书。

尝试安装 7.43.0.1 来解决您的问题。

pip install pycurl==7.43.0.1

如果这不起作用,请执行以下操作:

brew link curl
export LDFLAGS="-L/usr/local/opt/curl/lib"
export CPPFLAGS="-I/usr/local/opt/curl/include"

然后再试一次

pip install pycurl==7.43.0.1

推荐阅读