pip не может установить пакет - Dockerfile - PullRequest
1 голос
/ 09 июля 2019

Для приведенного ниже Dockerfile:

FROM openjdk:10.0.2-jdk


RUN     curl -sSLO https://files.pythonhosted.org/packages/1d/64/a18a487b4391a05b9c7f938b94a16d80305bf0369c6b0b9509e86165e1d3/setuptools-41.0.1.zip && \
    unzip setuptools-41.0.1.zip -d /tmp && \
    cd /tmp/setuptools-41.0.1 && \
    python setup.py install && \
    rm -rf /tmp/*

RUN curl -sSLO https://files.pythonhosted.org/packages/93/ab/f86b61bef7ab14909bd7ec3cd2178feb0a1c86d451bc9bccd5a1aedcde5f/pip-19.1.1.tar.gz && \
    tar  -xzvf pip-19.1.1.tar.gz -C /tmp && \
    cd /tmp/pip-19.1.1 && \
    python setup.py install && \
    rm -rf /tmp/*


ENV VERSION=0.17.0

RUN curl -sSLO https://github.com/awslabs/aws-sam-cli/releases/download/v$VERSION/aws-sam-cli-${VERSION}.x86_64_linux.bottle.tar.gz && \
    tar -C /usr/local/bin -zxvf /aws-sam-cli-${VERSION}.x86_64_linux.bottle.tar.gz

RUN pip install aws-sam-cli

Ниже приведена ошибка при загрузке и установке пакета pip. Невозможно изменить базовое изображение:

 Downloading https://files.pythonhosted.org/packages/03/8e/2424c0e65c4a066e28f539364deee49b6451f8fcd4f718fefa50cc3dcf48/backports.functools_lru_cache-1.5-py2.py3-none-any.whl
Installing collected packages: pytz, regex, tzlocal, six, python-dateutil, dateparser, chevron, enum34, scandir, pathlib2, Werkzeug, click, itsdangerous, MarkupSafe, Jinja2, Flask, jmespath, futures, docutils, urllib3, botocore, s3transfer, boto3, functools32, jsonschema, aws-sam-translator, wheel, aws-lambda-builders, chardet, idna, certifi, requests, future, backports.functools-lru-cache, arrow, jinja2-time, poyo, whichcraft, binaryornot, cookiecutter, PyYAML, serverlessrepo, websocket-client, ipaddress, backports.ssl-match-hostname, docker, aws-sam-cli
  Running setup.py install for regex: started
    Running setup.py install for regex: finished with status 'error'
    ERROR: Complete output from command /usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-8ydc0G/regex/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-b2VDRc/install-record.txt --single-version-externally-managed --compile:
    ERROR: BASE_DIR is /tmp/pip-install-8ydc0G/regex
    /usr/local/lib/python2.7/dist-packages/setuptools-41.0.1-py2.7.egg/setuptools/dist.py:472: UserWarning: Normalizing '2019.06.08' to '2019.6.8'
   running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/regex
    copying regex_2/regex/__init__.py -> build/lib.linux-x86_64-2.7/regex
    copying regex_2/regex/regex.py -> build/lib.linux-x86_64-2.7/regex
    copying regex_2/regex/_regex_core.py -> build/lib.linux-x86_64-2.7/regex
    creating build/lib.linux-x86_64-2.7/regex/test
    copying regex_2/regex/test/__init__.py -> build/lib.linux-x86_64-2.7/regex/test
    copying regex_2/regex/test/test_regex.py -> build/lib.linux-x86_64-2.7/regex/test
    running build_ext
    building 'regex._regex' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/regex_2
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fdebug-prefix-map=/build/python2.7-A8UpPM/python2.7-2.7.15=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c regex_2/_regex.c -o build/temp.linux-x86_64-2.7/regex_2/_regex.o
    unable to execute 'x86_64-linux-gnu-gcc': No such file or directory
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command "/usr/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-8ydc0G/regex/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-b2VDRc/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-8ydc0G/regex/
The command '/bin/sh -c pip install aws-sam-cli' returned a non-zero code: 1

Как устранить эту ошибку?

1 Ответ

1 голос
/ 09 июля 2019

Вам не хватает некоторых пакетов до сих пор.Dockerfile ниже устанавливает недостающие пакеты.Не уверен, что установка этих пакетов - это то, что вам нужно, но, по крайней мере, она даст вам понять, чего вам не хватает.Вот рабочая Dockerfile:

FROM openjdk:10.0.2-jdk


RUN curl -sSLO https://files.pythonhosted.org/packages/1d/64/a18a487b4391a05b9c7f938b94a16d80305bf0369c6b0b9509e86165e1d3/setuptools-41.0.1.zip && \
    unzip setuptools-41.0.1.zip -d /tmp && \
    cd /tmp/setuptools-41.0.1 && \
    python setup.py install && \
    rm -rf /tmp/*

RUN curl -sSLO https://files.pythonhosted.org/packages/93/ab/f86b61bef7ab14909bd7ec3cd2178feb0a1c86d451bc9bccd5a1aedcde5f/pip-19.1.1.tar.gz && \
    tar  -xzvf pip-19.1.1.tar.gz -C /tmp && \
    cd /tmp/pip-19.1.1 && \
    python setup.py install && \
    rm -rf /tmp/*


ENV VERSION=0.17.0

RUN curl -sSLO https://github.com/awslabs/aws-sam-cli/releases/download/v$VERSION/aws-sam-cli-${VERSION}.x86_64_linux.bottle.tar.gz && \
    tar -C /usr/local/bin -zxvf /aws-sam-cli-${VERSION}.x86_64_linux.bottle.tar.gz

RUN apt-get update; apt-get -y install python-dev build-essential

RUN pip install aws-sam-cli
...