Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

“Could not run curl-config: [Errno 2] No such file or directory” when installing pycurl on Alpine Linux

I'm trying to install pycurl via:

sudo pip install pycurl

It downloaded fine, but when when it runs setup.py I get the following traceback:

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

Any idea why this is happening and how to get around it using Alpine Linux?

like image 868
irishcoder Avatar asked Jun 21 '18 16:06

irishcoder


2 Answers

Found it. I believe this works.

# 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
like image 76
irishcoder Avatar answered Nov 12 '22 16:11

irishcoder


I had the same issue building a Tornado app based on python:3.7.2-apline3.9 image. I was able to get past this error used the curl-dev package as noted by pycURL's install instructions

Under the pycURL Install header:

NOTE: You need Python and libcurl installed on your system to use or build pycurl. Some RPM distributions of curl/libcurl do not include everything necessary to build pycurl, in which case you need to install the developer specific RPM which is usually called curl-dev.

Here is the relevant part of the 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

If you want to verify the features available through curl I did the following.

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

The output of curl --version is similar to

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

Specifically for me I was interested in the AsynchDNS being present so I could use Tornado's curl_httpclient

like image 27
TheDude Avatar answered Nov 12 '22 17:11

TheDude