在python wit messaage上构建图像需要很长时间:用于pandas的构建轮(pyproject.toml):仍在运行

7uhlpewt  于 2023-04-04  发布在  Python
关注(0)|答案(1)|浏览(173)

我在Python上构建Docker镜像时遇到了问题:下面的执行过程需要很长时间,大约20分钟:

Building wheel for pandas (pyproject.toml): still running...
Building wheel for pandas (pyproject.toml): still running...
Building wheel for pandas (pyproject.toml): still running...
Building wheel for pandas (pyproject.toml): still running...
Building wheel for pandas (pyproject.toml): still running...

Dockerfile

FROM python:3.11.2-buster
WORKDIR /app
COPY . .
RUN pip install -r /app/requirements.txt
CMD ["uvicorn", "main:app", "--host=0.0.0.0", "--port=80"]

requirement.txt

fastapi
uvicorn
pydantic[dotenv]
requests
python-dotenv==0.19.2
pandas==1.4.3
numpy==1.24.2
scikit-learn==1.2.2
yc0p9oo0

yc0p9oo01#

Pandas==1.4.3Python==3.11没有building wheel,因此回退是下载源存档(pandas-1.4.3.tar.gz)并从头开始构建它。您有两个选项:
1.在Dockerfile中将您的python版本从3.11降级到3.10:

FROM python:3.10.10-buster

1.在requirements.txt中将pandas版本从1.4.3升级到1.5.3:

pandas==1.5.3

(Python 3.10, Pandas 1.4)(Python 3.11, Pandas 1.5)这两种情况下,都不需要编译时间。

相关问题