Python 如何修复Docker依赖项安装?

Python 如何修复Docker依赖项安装?,python,macos,numpy,docker,pip,Python,Macos,Numpy,Docker,Pip,我有一个电影推荐系统,我正在尝试为它创建一个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

我有一个电影推荐系统,我正在尝试为它创建一个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的新手,请帮助。

这与docker无关。numpy、scipy等软件包需要在系统上安装
gcc
python-dev
软件包

尝试在Dockerfile中添加
apt get install-y python dev


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

看起来像是与
numpy
相关的问题,可能是由于库
setuptools
wheel
构建造成的

增加要求:

pip==19.0.2
setuptools==40.6.3
wheel==0.32.0
以下链接是为与AWS SageMaker一起使用而开发的,但可能对您有所帮助:


python开发包不可用,但被另一个包引用。这可能意味着该软件包丢失、已过时或仅可从其他来源获得,但以下软件包将替换它:pythone:package'python dev'没有安装候选程序。如何修复此问题?在运行installOP之前,您必须运行
apt get-y update
,而installOP中没有提到他使用的基本映像。它可以是没有apt的image“python:3”基于ubuntu?@AlexYu AFAIK,
python:3
基于Debian。()