我在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
1条答案
按热度按时间yc0p9oo01#
Pandas==1.4.3
和Python==3.11
没有building wheel,因此回退是下载源存档(pandas-1.4.3.tar.gz
)并从头开始构建它。您有两个选项:1.在
Dockerfile
中将您的python版本从3.11降级到3.10:1.在
requirements.txt
中将pandas版本从1.4.3升级到1.5.3:在
(Python 3.10, Pandas 1.4)
或(Python 3.11, Pandas 1.5)
这两种情况下,都不需要编译时间。