首页 > 解决方案 > 无法从 google.cloud 导入存储

问题描述

我是 Google Cloud Platform 的新手,并且已经在 DataLab 的 Jupyter notebook 上上传了一些机器学习代码。

我的问题是,虽然我安装了谷歌云存储(使用命令:)pip install --upgrade google-cloud-storage,但我无法导入它。

以下是我如何导入这个包:

>>import numpy    
>>import pandas as pd   
>>from google.cloud import storage

但我收到以下错误:

ImportErrorTraceback (最近一次调用最后一次) in () ----> 1 from google.cloud import storage

ImportError:无法导入名称存储

笔记:

  1. 这是我的 JSON 配置文件的内容:{"TokenSources":["env"]}
  2. 我试过export GOOGLE_APPLICATION_CREDENTIALS="/path/to/file.json"了,但错误仍然存​​在。
  3. 我通过在命令 shell 中键入 pip freeze 验证了这个包确实安装在我的环境中:

谷歌云==0.34.0

谷歌云数据存储==1.7.0

谷歌云扳手==1.4.0

谷歌云存储==1.10.0


我在这里想念什么?

标签: pythongoogle-cloud-platformjupyter-notebookgoogle-cloud-datalab

解决方案


所以我让它在导入存储时工作,如下所示:

导入 google.datalab.storage 作为存储


推荐阅读