繁体   English   中英

没有名为“google.cloud”的模块 Dockerfile python

[英]No module named 'google.cloud' Dockerfile python

我有一个带有google/cloud-sdk:alpine图像的 dockerfile。 当我运行它时,我不断收到一个错误,说我缺少一个模块,尽管我安装了它。

在构建我的图像时,我运行它

RUN pip install --upgrade google-api-python-client

在我的 Docker 容器中运行

 # pip show google-cloud

我得到以下 output

Name: google-cloud
Version: 0.34.0
Summary: API Client library for Google Cloud
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: googleapis-publisher@google.com
License: Apache 2.0
Location: /usr/lib/python3.6/site-packages
Requires: 
Required-by: 

然后我尝试运行 python 脚本并收到此错误

/ # python3 ./publisher.py local create test-topic-v1
Traceback (most recent call last):
  File "./publisher.py", line 318, in <module>
    create_topic(args.project_id, args.topic_name)
  File "./publisher.py", line 46, in create_topic
    from google.cloud import pubsub_v1
ModuleNotFoundError: No module named 'google.cloud'

google-api-python-client项目与google-cloud项目不同,不推荐使用https://pypi.org/project/google-cloud/项目:

警告:谷歌云 Python package 已弃用。 2018 年 6 月 18 日,此 package 将不再安装任何其他软件包。 请安装您的应用程序所需的产品特定的 google-cloud-* 软件包

您应该改为安装google-cloud-pubsub

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM