使用 Fedora 镜像在 Docker 上安装 pycurl

使用 Fedora 镜像在 Docker 上安装 pycurl

我正在尝试使用 Fedora 作为需要安装pycurl库的基础映像来编写 docker 文件。python 版本需要 3.6(项目要求)。

我在 OS X 10.14.6 上运行 Docker 桌面社区版本 2.0.1.1。

这是我的docker文件:

FROM fedora
USER root

RUN dnf -y install \
    openssl \
    openssl-devel \
    curl-devel \
    gcc

# Install python
RUN dnf -y install python36 

# upgrade pip
RUN pip3 install --upgrade pip

# install pycurl
RUN pip3 install --install-option="--with-openssl" pycurl 

以下是错误消息的相关部分:

In file included from src/docstrings.c:4:
    src/pycurl.h:4:10: fatal error: Python.h: No such file or directory
        4 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1

完整的错误信息如下:

Installing collected packages: pycurl
  Running setup.py install for pycurl: started
    Running setup.py install for pycurl: finished with status 'error'
/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py:243: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
  cmdoptions.check_install_build_global(options)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d7zb0v5y/pycurl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d7zb0v5y/pycurl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ngl4yqv3/install-record.txt --single-version-externally-managed --compile --with-openssl
         cwd: /tmp/pip-install-d7zb0v5y/pycurl/
    Complete output (20 lines):
    Using curl-config (libcurl 7.65.3)
    Using SSL library: OpenSSL/LibreSSL/BoringSSL
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.7
    creating build/lib.linux-x86_64-3.7/curl
    copying python/curl/__init__.py -> build/lib.linux-x86_64-3.7/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.linux-x86_64-3.7
    creating build/temp.linux-x86_64-3.7/src
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYCURL_VERSION="7.43.0.3" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/usr/include/python3.7m -c src/docstrings.c -o build/temp.linux-x86_64-3.7/src/docstrings.o
    In file included from src/docstrings.c:4:
    src/pycurl.h:4:10: fatal error: Python.h: No such file or directory
        4 | #include <Python.h>
          |          ^~~~~~~~~~
    compilation terminated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-d7zb0v5y/pycurl/setup.py'"'"'; __file__='"'"'/tmp/pip-install-d7zb0v5y/pycurl/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ngl4yqv3/install-record.txt --single-version-externally-managed --compile --with-openssl Check the logs for full command output.
The command '/bin/sh -c pip3 install --install-option="--with-openssl" pycurl' returned a non-zero code: 1

谢谢!

相关内容