【问题标题】:“Could not run curl-config: [Errno 2] No such file or directory” when installing pycurl on Alpine Linux在 Alpine Linux 上安装 pycurl 时“无法运行 curl-config: [Errno 2] No such file or directory”
【发布时间】:2018-12-01 02:21:04
【问题描述】:

我正在尝试通过以下方式安装 pycurl:

sudo pip install pycurl

它下载得很好,但是当它运行 setup.py 时,我得到以下回溯:

Downloading/unpacking pycurl
  Running setup.py egg_info for package pycurl
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>
        ext = get_extension()
      File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension
        ext_config = ExtensionConfiguration()
      File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__
        self.configure()
      File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix
        raise ConfigurationError(msg)
    __main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 16, in <module>
  File "/tmp/pip-build-root/pycurl/setup.py", line 563, in <module>
    ext = get_extension()
  File "/tmp/pip-build-root/pycurl/setup.py", line 368, in get_extension
    ext_config = ExtensionConfiguration()
  File "/tmp/pip-build-root/pycurl/setup.py", line 65, in __init__
    self.configure()
  File "/tmp/pip-build-root/pycurl/setup.py", line 100, in configure_unix
    raise ConfigurationError(msg)

__main__.ConfigurationError: Could not run curl-config: [Errno 2] No such file or directory

知道为什么会发生这种情况以及如何使用 Alpine Linux 解决它吗?

【问题讨论】:

    标签: python installation pycurl alpine


    【解决方案1】:

    找到了。我相信这行得通。

    # Install packages
    apk add --no-cache libcurl
    
    # Needed for pycurl
    ENV PYCURL_SSL_LIBRARY=openssl
    
    # Install packages only needed for building, install and clean on a single layer
    RUN apk add --no-cache --virtual .build-dependencies build-base curl-dev \
        && pip install pycurl \
        && apk del .build-dependencies
    

    【讨论】:

      【解决方案2】:

      我在构建基于 python:3.7.2-apline3.9 图像的 Tornado 应用程序时遇到了同样的问题。正如pycURL's install instructions 所指出的那样,我使用curl-dev 包能够克服这个错误

      在 pycURL 安装标头下:

      注意:您需要在系统上安装 Python 和 libcurl 才能使用或构建 pycurl。 curl/libcurl 的一些 RPM 发行版不包含构建 pycurl 所需的所有内容,在这种情况下,您需要安装开发人员特定的 RPM,通常称为 curl-dev。

      这里是Dockerfile的相关部分

      RUN apk add --no-cache libcurl
      RUN apk update \
          && apk add --virtual .build-deps \
              curl-dev \
          && pip install -e ./ \
          && apk --purge del .build-deps
      
      

      如果您想通过 curl 验证可用的功能,我执行了以下操作。

      docker exec -it <container_name> sh
      apk add curl
      curl --version
      
      

      curl --version 的输出类似于

      curl 7.64.0 (x86_64-alpine-linux-musl) libcurl/7.64.0 OpenSSL/1.1.1b zlib/1.2.11 libssh2/1.8.1 nghttp2/1.35.1
      Release-Date: 2019-02-06
      Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp 
      Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy
      
      

      特别是对我来说,我对存在的 AsynchDNS 很感兴趣,因此我可以使用 Tornado 的 curl_httpclient

      【讨论】:

        【解决方案3】:

        @irishcoder 我认为您需要在答案中添加“python3-dev”。 运行 apk add --no-cache --virtual .build-dependencies build-base curl-dev python3-dev \

        【讨论】:

        • 这应该是对现有答案的评论,而不是新答案
        • 我同意,我很抱歉。但我的代表不允许我这样做。
        猜你喜欢
        • 1970-01-01
        • 2018-01-21
        • 1970-01-01
        • 1970-01-01
        • 2016-06-07
        • 2017-07-05
        • 2018-11-20
        • 2018-07-24
        • 1970-01-01
        相关资源
        最近更新 更多