我有一个Dockerfile,它通过pip安装了几个包。其中一些需要grpcio,构建这一部分只需要几分钟。
有没有人有加速这一部分的小贴士?
Installing collected packages: python-dateutil, azure-common, azure-nspkg, azure-storage, jmespath, docutils, botocore, s3transfer, boto3, smmap2, gitdb2, GitPython, grpcio, protobuf, googleapis-common-protos, grpc-google-iam-v1, pytz, google-api-core, google-cloud-pubsub
Found existing installation: python-dateutil 2.7.3
Uninstalling python-dateutil-2.7.3:
Successfully uninstalled python-dateutil-2.7.3
Running setup.py install for grpcio: started
Running setup.py install for grpcio: still running...
Running setup.py install for grpcio: still running...
Running setup.py install for grpcio: still running...谢谢。
发布于 2020-08-25 00:55:45
我也遇到了同样的问题,通过升级pip解决了这个问题:
$ pip3 install --upgrade pip下面是grpc项目的维护者之一说的话:
发布于 2019-06-04 23:32:47
有相同的问题,通过使用virtualenv和多阶段dockerfile修复了它:
FROM python:3.7-slim as base
# ---- compile image -----------------------------------------------
FROM base AS compile-image
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential \
gcc
RUN python -m venv /app/env
ENV PATH="/app/env/bin:$PATH"
COPY requirements.txt .
RUN pip install --upgrade pip
# pip install is fast here (while slow without the venv) :
RUN pip install -r requirements.txt
# ---- build image -----------------------------------------------
FROM base AS build-image
COPY --from=compile-image /app/env /app/env
# Make sure we use the virtualenv:
ENV PATH="/app/env/bin:$PATH"
COPY . /app
WORKDIR /app这是我的requirements.txt:
fastapi==0.27.*
grpcio-tools==1.21.*
uvicorn==0.7.*发布于 2022-01-17 21:35:04
一些码头图像(看着你,阿尔卑斯山)不能拉预置的轮子。使用可以的docker镜像,比如Debian。
看看这个nice write-up on why。我将引用其中的一句话,这特别贴切:
但是对于Python,因为
不使用用于构建Python扩展的标准工具,所以在安装包时,在许多情况下Python (pip)不会找到用于Python的预编译可安装包(“轮子”)。在调试了许多奇怪的错误之后,您将意识到,仅仅为了使用这些常见的Python包,您就必须安装许多额外的工具并构建许多依赖项。-- Sebastián Ramírez
https://stackoverflow.com/questions/52904639
复制相似问题