导入云存储,导入错误:没有名为 google.appengine.api 的模块

导入云存储,导入错误:没有名为 google.appengine.api 的模块

问题描述:

我想使用 Google 云存储客户端库函数一>.

为此,我必须导入cloudstorag.为了获得 cloudstorage,我下载了 Google Cloud Storage 客户端库.

For that I have to import the cloudstorag. To get the cloudstorage I download Google Cloud Storage client library.

我尝试使用 python -c "import cloudstorage" 导入云存储.我收到以下错误:

I try to import cloudstorage using python -c "import cloudstorage". I get the following error:

Traceback (most recent call last):
File "<string>", line 1, in <module>
  File "cloudstorage/__init__.py", line 20, in <module>
    from .api_utils import RetryParams
  File "cloudstorage/api_utils.py", line 45, in <module>
    from google.appengine.api import app_identity
ImportError: No module named google.appengine.api

我错过了什么吗?

当您执行 python -c "import cloudstorage" 时,您正在尝试运行一个独立的应用程序.但是您尝试使用的 GCS 库用于(标准环境)GAE 应用程序,它不能作为独立应用程序执行,它需要在 GAE 沙箱中运行(本地为 dev_appserver.py).请参阅 GAE:断言错误:无 api 代理找到服务datastore_v3".

When you execute python -c "import cloudstorage" you're attempting to run a standalone application. But the GCS library you're trying to use is for a (standard environment) GAE application, which cannot be executed as a standalone app, it needs to run in a GAE sandbox (locally that's dev_appserver.py). See GAE: AssertionError: No api proxy found for service "datastore_v3".

该库需要安装在您的 GAE 应用程序中,请参阅 复制第三方库.

And the library needs to be installed inside your GAE app, see Copying a third-party library.

如果您不是在开发标准的 env GAE 应用程序,并且确实想编写一个独立的应用程序,那么您没有查看正确的文档.您需要使用与 GAE 特定的库不同的库.请参阅云存储客户端库

If you're not developing a standard env GAE app and indeed you want to write a standalone one, you're not looking at the right documentation. You need to use a different library than the GAE-specific one(s). See Cloud Storage Client Libraries