【问题标题】:How to fix Docker dependencies installation?如何修复 Docker 依赖项安装?
【发布时间】:2019-07-09 12:27:39
【问题描述】:

我有一个电影推荐系统,我正在尝试为它创建一个 docker 映像。

requirements.txt

pandas==0.22.0
requests==2.18.4
Django==2.0.6
Scrapy==1.5.1
numpy==1.14.0
scipy==1.0.0
pymongo==3.7.2

Dockerfile:

FROM python:3
MAINTAINER SPARSH KEDIA

ENV PYTHONUNBUFFERED 1

COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

RUN mkdir /app
WORKDIR /app
COPY ./app /app

RUN adduser -D user
USER user

在运行 docker build 时,它显示以下错误:

error: Command "gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -Inumpy/core/include -Ibuild/src.linux-x86_64-3.7/numpy/core/include/numpy -Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -I/usr/local/include/python3.7m -Ibuild/src.linux-x86_64-3.7/numpy/core/src/private -Ibuild/src.linux-x86_64-3.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-3.7/numpy/core/src/private -Ibuild/src.linux-x86_64-3.7/numpy/core/src/npymath -Ibuild/src.linux-x86_64-3.7/numpy/core/src/private -Ibuild/src.linux-x86_64-3.7/numpy/core/src/npymath -c numpy/random/mtrand/mtrand.c -o build/temp.linux-x86_64-3.7/numpy/random/mtrand/mtrand.o -MMD -MF build/temp.linux-x86_64-3.7/numpy/random/mtrand/mtrand.o.d" failed with exit status 1


  Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-ug5tncvh/numpy/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-zziwp791/install-record.txt --single-version-externally-managed --prefix /tmp/pip-build-env-wpkwq_6g/overlay --compile" failed with error code 1 in /tmp/pip-install-ug5tncvh/numpy/

  ----------------------------------------
Command "/usr/local/bin/python /usr/local/lib/python3.7/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-wpkwq_6g/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- wheel setuptools Cython "numpy==1.9.3; python_version=='3.5'" "numpy==1.12.1; python_version=='3.6'" "numpy==1.13.1; python_version>='3.7'"" failed with error code 1 in None
The command '/bin/sh -c pip install -r /requirements.txt' returned a non-zero code: 1

如何解决这个错误?或者有其他方法可以下载 requirements.txt 吗?

我使用 macOS HighSierra 10.13.2。

我是 docker 新手,请帮忙。

【问题讨论】:

    标签: python macos numpy docker pip


    【解决方案1】:

    看起来是与numpy 相关的问题,可能是由于库setuptoolswheel 构建所致。

    添加到要求:

    pip==19.0.2
    setuptools==40.6.3
    wheel==0.32.0
    

    以下此链接是为与 AWS SageMaker 一起使用而开发的,但也许可以帮助您:

    Dockerfile

    【讨论】:

      【解决方案2】:

      这与 Docker 无关。 numpy、scipy等包需要在系统上安装gccpython-dev包。

      尝试在 Dockerfile 中添加apt-get install -y python-dev 作为步骤。

      PS:这些库可能还有其他系统包依赖项。请检查并安装它们。

      【讨论】:

      • 包 python-dev 不可用,但被另一个包引用。这可能意味着该软件包丢失、已过时或只能从其他来源获得但是以下软件包替换它:python E:软件包“python-dev”没有安装候选者。如何解决这个问题?
      • 您必须在运行安装之前运行apt-get -y update
      • OP 没有提到他使用的基本图像。没有apt“python:3”可能是基于ubuntu的图像?
      • @AlexYu AFAIK, python:3 基于 Debian。 (github.com/docker-library/python)
      猜你喜欢
      • 1970-01-01
      • 2019-11-06
      • 1970-01-01
      • 2019-01-04
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多