简体   繁体   English

import cloudstorage,ImportError:没有名为google.appengine.api的模块

[英]import cloudstorage, ImportError: No module named google.appengine.api

I would like to use Google Cloud Storage Client Library Functions . 我想使用Google云端存储客户端库函数

For that I have to import the cloudstorag . 为此,我必须导入cloudstorag To get the cloudstorage I download Google Cloud Storage client library . 为了得到cloudstorage我下载谷歌云存储客户端库

I try to import cloudstorage using python -c "import cloudstorage" . 我尝试使用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

Am I missing something? 我错过了什么吗?

When you execute python -c "import cloudstorage" you're attempting to run a standalone application. 执行python -c "import cloudstorage"您尝试运行独立应用程序。 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 ). 但是您尝试使用的GCS库是用于(标准环境)GAE应用程序,它不能作为独立应用程序执行,它需要在GAE沙箱中运行(本地的dev_appserver.py )。 See GAE: AssertionError: No api proxy found for service "datastore_v3" . 请参阅GAE:AssertionError:找不到服务“datastore_v3”的api代理

And the library needs to be installed inside your GAE app, see Copying a third-party library . 并且库需要安装在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. 如果您没有开发标准的env GAE应用程序,而且您确实想要编写一个独立的应用程序,那么您就不会查看正确的文档。 You need to use a different library than the GAE-specific one(s). 您需要使用与GAE特定的库不同的库。 See Cloud Storage Client Libraries 请参阅云存储客户端库

Looks like gcloud is not installed on your system. 看起来你的系统上没有安装gcloud。

pip install --upgrade gcloud pip install --upgrade gcloud

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

You can add this lines, which will add the path of the sdk tools: 您可以添加此行,这将添加sdk工具的路径:

import pkgutil
import google

google.__path__ = pkgutil.extend_path(google.__path__, google.__name__)

For unittesting, it could be useful to run in standalone mode. 对于单元测试,在独立模式下运行可能很有用。

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

相关问题 ImportError:没有名为google.appengine.api的模块 - ImportError: No module named google.appengine.api 无法导入google.appengine.api - can't import google.appengine.api 尝试从google.appengine.api中导入background_thread(例如示例)失败,并出现ImportError - Trying to Import background_thread from google.appengine.api (like in example) fails with ImportError 在python flex环境中导入错误google.appengine.api - Import error google.appengine.api in python flex environment ImportError:没有名为appengine.api的模块 - ImportError: No module named appengine.api Visual Code pylint:无法导入 webapp2 和 google.appengine.api - Visual Code pylint: unable to import webapp2 and google.appengine.api 升级到 GAE3 时替换 google.appengine.api 导入模块 - Replacing google.appengine.api import modules when upgrading to GAE3 Google App Engine(Python 2.7)Win 10 ImportError:没有名为appengine.api的模块 - Google App Engine (Python 2.7) Win 10 ImportError: No module named appengine.api 在 Ubuntu 18.04 中找不到 Python google.appengine.api - Python google.appengine.api not found in Ubuntu 18.04 Google App Engine:ImportError:没有名为appengine.ext的模块 - Google App Engine: ImportError: No module named appengine.ext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM