[英]from google.cloud import storage fails: ImportError: No module named google.cloud
I'm having issue with accessing Google Storage through Python 3.6.I'm installing with:我在通过 Python 3.6 访问 Google Storage 时遇到问题。我正在安装:
pip install --upgrade google-cloud-storage
Here's my Python script:这是我的 Python 脚本:
from google.cloud import storage
def main():
client = storage.Client()
bucket = client.get_bucket('my_bucket')
blob1 = bucket.blob('my_file.json')
blob1.upload_from_filename(filename='my_file.json')
if __name__ == "__main__":
main()
pip show google-cloud-storage
gives me following output: pip show google-cloud-storage
给了我以下输出:
Name: google-cloud-storage
Version: 1.6.0
Summary: Python Client for Google Cloud Storage
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/local/lib/python3.6/dist-packages
Requires: google-api-core, google-auth, google-cloud-core, requests, google-resumable-media
Any idea what's wrong here?知道这里有什么问题吗?
There is a chance you are installing it with one python
version (Eg python2
) and running your code with another version (Eg python3
).您有可能使用一个
python
版本(例如python2
)安装它并使用另一个版本(例如python3
)运行您的代码。
Try mentioning versions of pip
and python
in the command.尝试在命令中提及
pip
和python
版本。
To be precise, use pip of the python version you wanna run the code with.准确地说,使用你想要运行代码的 python 版本的 pip。 Example:
示例:
python3.6 -m pip install --upgrade google-cloud-storage
There could be multiple versions of Python installed on your system and multiple versions of pip
as well, the above will make sure you are using the correct version of both .有可能是Python的多个版本的系统和多个版本上安装
pip
还有,上面会确保你同时使用的正确版本。
我遇到了同样的问题并通过以管理员身份运行我的脚本来解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.