pip install google-cloud-pubsub无法在docker容器中安装 [英] pip install google-cloud-pubsub fails install in docker container

查看:166
本文介绍了pip install google-cloud-pubsub无法在docker容器中安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用pupsub模拟器。它开始了,但是当我尝试使用python脚本时,出现以下错误

I am trying to use a pupsub emulator. It starts but when I try to use my python script I get the following error

ModuleNotFoundError: No module named 'google'

所以我尝试安装模块。

RUN pip install google-cloud-pubsub

错误

ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.6 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-2hyoy1ly/grpcio/setup.py'"'"'; __file__='"'"'/tmp/pip-install-2hyoy1ly/grpcio/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-m25l52fe
         cwd: /tmp/pip-install-2hyoy1ly/grpcio/
    Complete output (11 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-2hyoy1ly/grpcio/setup.py", line 191, in <module>
        if check_linker_need_libatomic():
      File "/tmp/pip-install-2hyoy1ly/grpcio/setup.py", line 152, in check_linker_need_libatomic
        stderr=PIPE)
      File "/usr/lib/python3.6/subprocess.py", line 729, in __init__
        restore_signals, start_new_session)
      File "/usr/lib/python3.6/subprocess.py", line 1364, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    FileNotFoundError: [Errno 2] No such file or directory: 'cc': 'cc'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Service 'praise-pubsub' failed to build: The command '/bin/sh -c pip install google-cloud-pubsub==0.24.0' returned a non-zero code: 1

完整的Dockerfile

full Dockerfile

FROM google/cloud-sdk:alpine
RUN gcloud components install pubsub-emulator

FROM openjdk:jre-alpine


ENV PYTHONUNBUFFERED=1

RUN echo "**** install Python ****" && \
    apk add --no-cache python3 && \
    if [ ! -e /usr/bin/python ]; then ln -sf python3 /usr/bin/python ; fi && \
    \
    echo "**** install pip ****" && \
    python3 -m ensurepip && \
    rm -r /usr/lib/python*/ensurepip && \
    pip3 install --no-cache --upgrade pip setuptools wheel && \
    if [ ! -e /usr/bin/pip ]; then ln -s pip3 /usr/bin/pip ; fi

#RUN pip install google-cloud <--- still fails when this is here
#RUN pip install Cython --install-option="--no-cython-compile" <--- still fails
RUN pip install google-cloud-pubsub
COPY --from=0 /google-cloud-sdk/platform/pubsub-emulator /pubsub-emulator


推荐答案

为了安装该客户端,您需要在其中安装gcc您的Docker容器。它正在尝试使用cc命令来编译库的一部分。尝试在google-cloud-pubsub软件包之前安装cython软件包。

It looks like in order to install that client, you need gcc installed in your docker container. It is trying to use the cc command to compile part of the library. Try installing the cython package prior to the google-cloud-pubsub package.

还要注意,Google Cloud Pub / Sub客户端库的0.24.0版本是三岁;现在,它的版本为1.5.0。此依赖性问题(以及许多其他问题)可能已在此期间修复,因此可能值得更新至较新版本。

It is also worth noting that version 0.24.0 of the Google Cloud Pub/Sub client library is three years old; it is now up to version 1.5.0. This dependency issue (along with many other things) may have been fixed somewhere in the meantime, so it might be worth updating to a more recent version.

这篇关于pip install google-cloud-pubsub无法在docker容器中安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆