Python docker构建与gRPC一起失败
我正在尝试从docker运行gRPC客户端。docker文件如下所示:Python docker构建与gRPC一起失败,python,docker,dockerfile,runtime,ubuntu-20.04,Python,Docker,Dockerfile,Runtime,Ubuntu 20.04,我正在尝试从docker运行gRPC客户端。docker文件如下所示: # set base image (host OS) FROM python:3.8 # set the working directory in the container WORKDIR /code # copy the dependencies file to the working directory COPY requirements.txt . # install dependencies RUN pip
# set base image (host OS)
FROM python:3.8
# set the working directory in the container
WORKDIR /code
# copy the dependencies file to the working directory
COPY requirements.txt .
# install dependencies
RUN pip install -r requirements.txt
# copy the content of the local src directory to the working directory
COPY src/ .
# command to run on container start
CMD [ "python3", "./greeter_client.py" ]
码头工人建造。命令引发以下错误
(base) jatin@jatin:~/Docker/helloworld$ sudo docker build .
Sending build context to Docker daemon 27.65kB
Step 1/6 : FROM python:3.8
---> a7cda474cef4
Step 2/6 : WORKDIR /code
---> Using cache
---> e73b4d4bb30f
Step 3/6 : COPY requirements.txt .
---> Using cache
---> e7b359fa7531
Step 4/6 : RUN pip install -r requirements.txt
---> Running in 2aef16eeaadc
Collecting grpcio==1.31.0
Downloading grpcio-1.31.0-cp38-cp38-manylinux2014_x86_64.whl (3.4 MB)
Collecting grpc==1.0.0
Downloading grpc-1.0.0.tar.gz (5.2 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-6jhodm6k/grpc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-6jhodm6k/grpc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-10g87t80
cwd: /tmp/pip-install-6jhodm6k/grpc/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-6jhodm6k/grpc/setup.py", line 33, in <module>
raise RuntimeError(HINT)
RuntimeError: Please install the official package with: pip install grpcio
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(基本)jatin@jatin:~/Docker/helloworld$sudo Docker build。
正在将生成上下文发送到Docker守护程序27.65kB
步骤1/6:来自python:3.8
--->a7cda474cef4
步骤2/6:WORKDIR/代码
--->使用缓存
--->e73b4d4bb30f
步骤3/6:复制requirements.txt。
--->使用缓存
--->e7b359fa7531
步骤4/6:运行pip安装-r requirements.txt
--->在2aef16eeaadc中运行
正在收集的grpcio==1.31.0
下载grpcio-1.31.0-cp38-cp38-manylinux2014_x86_64.whl(3.4 MB)
正在收集的grpc==1.0.0
下载grpc-1.0.0.tar.gz(5.2kb)
错误:命令出错,退出状态为1:
命令:/usr/local/bin/python-c'import sys、setuptools、tokenize;sys.argv[0]=“tmp/pip-install-6jhodm6k/grpc/setup.py”“”__文件为“'''/tmp/pip-install-6jhodm6k/grpc/setup.py'”;f=getattr(标记化,“'open'”,open)(\uuuuu文件);code=f.read().replace(“\r\n”“”、“\n”“”);f、 close();exec(编译(代码,uuuu文件,“'exec'))'egg\u info--egg base/tmp/pip-pip-egg-info-10g87t80
cwd:/tmp/pip-install-6jhodm6k/grpc/
完整输出(5行):
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
文件“/tmp/pip-install-6jhodm6k/grpc/setup.py”,第33行,在
引发运行时错误(提示)
运行时错误:请使用以下命令安装官方软件包:pip install grpcio
----------------------------------------
错误:命令出错,退出状态为1:python setup.py egg_info检查日志以获得完整的命令输出。
我在网上找不到类似的错误。我假设所有的python库都可以在Python3.8中找到。请帮我找到解决办法。
提前感谢从您的requirements.txt中删除
grpc
。真正的软件包是grpcio
,您似乎已经包含了它。这很有效。非常感谢。