我在Google Computing上启动了一个实例,并安装了google-cloud
,但是当我尝试运行python代码:python3 sensorgen.py
时,我得到了:
root@nomad-clients-rp-4bhr:/usr/local/lib/python3.5/dist-packages# python3 ~/sensorgen.py
Traceback (most recent call last):
File "/root/sensorgen.py", line 6, in <module>
from google.cloud import pubsub_v1
ImportError: No module named 'google'
但已安装。...
root@nomad-clients-rp-4bhr:/usr/local/lib/python3.5/dist-packages# pip3 show google-cloud
---
Metadata-Version: 2.1
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
Installer: pip
License: Apache 2.0
Location: /usr/local/lib/python3.5/dist-packages
Requires:
Classifiers:
Development Status :: 7 - Inactive
Intended Audience :: Developers
License :: OSI Approved :: Apache Software License
Operating System :: OS Independent
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.4
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3.6
Topic :: Internet
You are using pip version 8.1.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
我已经完成pip3 install google-cloud --upgrade
...的操作,然后卸载并重新安装,但还是行不通。...
答案 0 :(得分:1)
好像您想将pubsub与python一起使用,根据documentation,应使用以下命令安装模块:
pip install --upgrade google-cloud-pubsub
如果这不起作用,您可以使用apt更新pip和pip3:
sudo apt install python3-pip python-pip
pip install --upgrade google-cloud-pubsub
答案 1 :(得分:0)
只需尝试pip install google
并重新执行python脚本
还要升级点子