用于安装构建依赖项的 pip 子进程未成功运行[重复]

问题描述 投票:0回答:1

使用以下 docker 文件,

FROM python:3.9-slim-buster

WORKDIR /python-docker

COPY requirements.txt requirements.txt

RUN python3 -m pip install --upgrade pip

RUN pip3 install -r requirements.txt

COPY . .

EXPOSE 5000

CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]

需求文件如下,

boto3==1.21.32
Flask==2.2.2
Flask_Cors==3.0.10
hvac==1.0.2
PyJWT==2.6.0
PyMySQL==0.10.1
zenpy==2.0.24
gunicorn==20.1.0
pandas==1.4.2

当我尝试使用以下命令构建多弧 docker 文件时,

docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t name/flask-docker:latest --push .

它显示以下输出:

× pip subprocess to install build dependencies did not run successfully.
#0 148.6   │ exit code: 1
#0 148.6   ╰─> [262 lines of output]
#0 148.6       Collecting setuptools>=51.0.0
#0 148.6         Downloading setuptools-65.6.0-py3-none-any.whl (1.2 MB)
#0 148.6            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 7.0 MB/s eta 0:00:00
#0 148.6       Collecting wheel
#0 148.6         Downloading wheel-0.38.4-py3-none-any.whl (36 kB)
#0 148.6       Collecting Cython<3,>=0.29.24
#0 148.6         Downloading Cython-0.29.32-py2.py3-none-any.whl (986 kB)
#0 148.6            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 986.3/986.3 kB 9.1 MB/s eta 0:00:00
#0 148.6       Collecting oldest-supported-numpy>=0.10
#0 148.6         Downloading oldest_supported_numpy-2022.11.19-py3-none-any.whl (4.9 kB)
#0 148.6       Collecting numpy==1.19.3
#0 148.6         Downloading numpy-1.19.3.zip (7.3 MB)
#0 148.6            ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.3/7.3 MB 13.4 MB/s eta 0:00:00
#0 148.6         Installing build dependencies: started
#0 148.6         Installing build dependencies: finished with status 'done'
#0 148.6         Getting requirements to build wheel: started
#0 148.6         Getting requirements to build wheel: finished with status 'done'
#0 148.6         Preparing metadata (pyproject.toml): started
#0 148.6         Preparing metadata (pyproject.toml): still running...
#0 148.6         Preparing metadata (pyproject.toml): finished with status 'error'
#0 148.6         error: subprocess-exited-with-error
#0 148.6       
#0 148.6         × Preparing metadata (pyproject.toml) did not run successfully.
#0 148.6         │ exit code: 1
#0 148.6         ╰─> [227 lines of output]
#0 148.6             Running from numpy source directory.
#0 148.6             setup.py:480: UserWarning: Unrecognized setuptools command, proceeding with generating Cython sources and expanding templates
#0 148.6               run_build = parse_setuppy_commands()
#0 148.6             Processing numpy/random/_bounded_integers.pxd.in
#0 148.6             Processing numpy/random/_common.pyx
#0 148.6             Processing numpy/random/_mt19937.pyx
#0 148.6             Processing numpy/random/_philox.pyx
#0 148.6             Processing numpy/random/mtrand.pyx
#0 148.6             Processing numpy/random/bit_generator.pyx


RuntimeError: Broken toolchain: cannot link a simple C program
#0 148.6             [end of output]
#0 148.6       
#0 148.6         note: This error originates from a subprocess, and is likely not a problem with pip.
#0 148.6       error: metadata-generation-failed
#0 148.6       
#0 148.6       × Encountered error while generating package metadata.
#0 148.6       ╰─> See above for output.
#0 148.6       
#0 148.6       note: This is an issue with the package mentioned above, not pip.
#0 148.6       hint: See above for details.
#0 148.6       [end of output]
#0 148.6   
#0 148.6   note: This error originates from a subprocess, and is likely not a problem with pip.
#0 148.6 error: subprocess-exited-with-error
#0 148.6 
#0 148.6 × pip subprocess to install build dependencies did not run successfully.
#0 148.6 │ exit code: 1
#0 148.6 ╰─> See above for output.
#0 148.6 
#0 148.6 note: This error originates from a subprocess, and is likely not a problem with pip.
------
Dockerfile:9
--------------------
   7 |     RUN python3 -m pip install --upgrade pip
   8 |     
   9 | >>> RUN pip3 install -r requirements.txt

正如上面的问题所说,这不是 pip 的问题,无法准确判断是否是任何底层包的问题?

注意:我尝试从需求文件中删除 pandas 并且它正在工作,但我需要它,因为我有一个基于此的导入。

python docker pip
1个回答
0
投票

好的,只需尝试一个一个地安装软件包,或者您可以删除每个软件包后的版本,这样它就会自动调整 就像这样

boto3
Flask
Flask_Cors
hvac
PyJWT
PyMySQL
zenpy
gunicorn
pandas
#I think it will work fine
© www.soinside.com 2019 - 2024. All rights reserved.