[英]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.