泊坞窗中的Python错误-distutils.errors.CompileError:命令'gcc'失败,退出状态为1 [英] Python error in docker - distutils.errors.CompileError: command 'gcc' failed with exit status 1
问题描述
我正在尝试在docker映像中安装google-cloud-pubsub。要求之一是安装grpcio。尝试安装grpcio时,出现类似 distutils.errors.CompileError:命令'gcc'失败,退出状态为1的错误。
我也已经安装了这些软件包-> pip install --upgrade wheel numpy熊猫cython六
使用的版本:Python 3.6.9&来自/usr/lib/python3.6/site-packages/pip(python 3.6)的pip 20.1.1
追溯(最近一次调用) :
,文件 /tmp/pip-install-gtay96uw/grpcio/src/python/grpcio/commands.py,第262行,位于build_extensions
build_ext.build_ext.build_extensions(self)$ b $中b在build_extensions
_build_ext.build_ext.build_extensions(self)
文件 /usr/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py中,第195行。 /usr/lib/python3.6/distutils/command/build_ext.py,第448行,位于build_extensions
self._build_extensions_serial()
文件 /usr/lib/python3.6/distutils/ _build_extensions_serial
self.build_extension(ext)
中的命令/build_ext.py,第473行, / usr / lib / python3.6 / site-packages / setuptools / command / build_ext.py第208行,在build_extension
_build_ext.build_extension(self,ext)
文件 /usr/lib/python3.6/distut中il / command / build_ext.py,第533行,位于build_extension
Depend = ext.depends)
文件 /usr/lib/python3.6/distutils/ccompiler.py,第574行,在编译
self._compile(obj,src,ext,cc_args,extra_postargs,pp_opts)中
文件 /tmp/pip-install-gtay96uw/grpcio/src/python/grpcio/commands.py new_compile
pp_opts)中的第246行,
文件 /usr/lib/python3.6/distutils/unixccompiler.py,_compile
中的第120行,引发CompileError(msg)
distutils.errors.CompileError:命令'gcc'失败,退出状态为1
------------------------ ----------------
**错误:grpcio
的构建轮失败运行grupcio的setup.py clean **
还尝试了其他版本的google-cloud-pubsub-> 1.5.0、1.6.1。全部以相同的错误结尾。
我的Docker文件如下所示。
### 1。从高山获得Linux
:3.7
### 2.通过程序包管理器
获取Java运行apk更新\
& apk升级\
&& apk添加--no-cache bash \
&& apk添加--no-cache --virtual = build-dependencies解压缩\
&& apk添加--no-cache curl \
&& apk add --no-cache openjdk8-jre
####可选:4.设置JAVA_HOME环境变量,如果需要它,请取消注释下面的行
ENV JAVA_HOME = / usr /lib/jvm/java-1.8-openjdk
ENV PATH =" $ JAVA_HOME / bin:$ {PATH}"
运行其中的Java&& java -version
RUN echo $ PATH
#FROM python:3.7.5-alpine3.9
### 3.获取Python,PIP
apk add --no-cache python3 \
&& python3 -m surepip \
&& pip3 install --upgrade pip setuptools \
&& rm -r / usr / lib / python * / ensurepip&& if
如果[! -e / usr / bin / pip];然后ln -s pip3 / usr / bin / pip; fi&& if
如果[[! -e / usr / bin / python]];然后ln -sf / usr / bin / python3 / usr / bin / python; fi&& \
rm -r /root/.cache
RUN apk --update add --no-cache gcc python3-dev musl-dev g ++
RUN apk --update add gpgme-dev libc-dev
来自gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
运行gcloud组件安装gsutil bq
我也在高山linux上遇到此问题。
apk add python-dev
使用此代码解决。 / p>
I am trying to install google-cloud-pubsub in a docker image. One of the requirement is to install grpcio. While trying to install grpcio, I get an error like "distutils.errors.CompileError: command 'gcc' failed with exit status 1"
I have also installed these packages -> pip install --upgrade wheel numpy panda cython six
Version used : Python 3.6.9 & pip 20.1.1 from /usr/lib/python3.6/site-packages/pip (python 3.6)
Traceback (most recent call last):
File "/tmp/pip-install-gtay96uw/grpcio/src/python/grpcio/commands.py", line 262, in build_extensions
build_ext.build_ext.build_extensions(self)
File "/usr/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
_build_ext.build_ext.build_extensions(self)
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
self._build_extensions_serial()
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
self.build_extension(ext)
File "/usr/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/usr/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/usr/lib/python3.6/distutils/ccompiler.py", line 574, in compile
self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
File "/tmp/pip-install-gtay96uw/grpcio/src/python/grpcio/commands.py", line 246, in new_compile
pp_opts)
File "/usr/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1
----------------------------------------
**ERROR: Failed building wheel for grpcio
Running setup.py clean for grpcio**
Tried other version of google-cloud-pubsub as well -> 1.5.0, 1.6.1. All ending with the same error.
My Docker file looks like below.
### 1. Get Linux
FROM alpine:3.7
### 2. Get Java via the package manager
RUN apk update \
&& apk upgrade \
&& apk add --no-cache bash \
&& apk add --no-cache --virtual=build-dependencies unzip \
&& apk add --no-cache curl \
&& apk add --no-cache openjdk8-jre
#### OPTIONAL : 4. SET JAVA_HOME environment variable, uncomment the line below if you need it
ENV JAVA_HOME="/usr/lib/jvm/java-1.8-openjdk"
ENV PATH="$JAVA_HOME/bin:${PATH}"
RUN which java && java -version
RUN echo $PATH
#FROM python:3.7.5-alpine3.9
### 3. Get Python, PIP
RUN apk add --no-cache python3 \
&& python3 -m ensurepip \
&& pip3 install --upgrade pip setuptools \
&& rm -r /usr/lib/python*/ensurepip && \
if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi && \
if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi && \
rm -r /root/.cache
RUN apk --update add --no-cache gcc python3-dev musl-dev g++
RUN apk --update add gpgme-dev libc-dev
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
RUN gcloud components install gsutil bq
I was also getting this problem on alpine linux.
apk add python-dev
solved with this code.
这篇关于泊坞窗中的Python错误-distutils.errors.CompileError:命令'gcc'失败,退出状态为1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!