[英]App Engine Error No module google.cloud.speech and appengine.api
I'm using Google Cloud AppEngine based on the examples provided on Github I was testing the blobstore example but when I try to include the API google.cloud.speech in that example I get the error "No module named google.cloud.speech" but in the speech demo the same import it works. 我正在使用基于Github上提供的示例的Google Cloud AppEngine,正在测试blobstore示例,但是当我尝试在该示例中包含API google.cloud.speech时,出现错误“没有名为google.cloud.speech的模块”但在语音演示中,同样的导入效果也可以。
dev_appserver.py app.yaml
dev_appserver.py app.yaml
In the speech demo when I include the import google.appengine.api I have the error No module named appengine.api, but the same import it works on the blobstore example. 在语音演示中,当我包含导入google.appengine.api时,出现错误No模块名为appengine.api,但相同的导入在blobstore示例中起作用。
python2.7 transcribeSpeech.py resources/audio.raw
python2.7 transcribeSpeech.py资源/audio.raw
First Error 第一个错误
ERROR 2018-01-17 12:07:09,600 wsgi.py:263]
Traceback (most recent call last):
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/user/src/project/python_gae_quickstart_editor-2018-01-14-21-40/appengine/standard/blobstore/gcs/main.py", line 13, in <module>
from google.cloud import speech
File "/google/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1147, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.cloud.speech
Second error: 第二个错误:
Traceback (most recent call last):
File "transcribeSpeech.py", line 39, in <module>
import cloudstorage
File "/home/user/src/project/python_gae_quickstart_editor-2018-01-14-21-40/appengine/standard/blobstore/gcs/lib/cloudstorage/__init__.py", line 20, in <module>
from .api_utils import RetryParams
File "/home/user/src/project/python_gae_quickstart_editor-2018-01-14-21-40/appengine/standard/blobstore/gcs/lib/cloudstorage/api_utils.py", line 45, in <module>
from google.appengine.api import app_identity
ImportError: No module named appengine.apiv
You're mixing up standard env GAE apps (your 1st invocation) with standalone python apps (your 2nd invocation) - not the same thing, they don't work the same way, so don't make behaviour comparisons between them expecting to be the same/similar. 您正在将标准的env GAE应用程序(您的第一个调用)与独立的python应用程序(您的第二个调用)混合在一起-不一样,它们的工作方式不同,因此不要在期望的情况下进行行为比较相同/相似。 See GAE works but import webapp2 failed in Spyder .
请参阅GAE的作品,但在Spyder中导入webapp2失败 。
If your app is a GAE standard app (the only ones supported by dev_appserver.py
) then you have to vendor in all additional libraries inside your app (GAE doesn't know/care about libraries installed in your virtual env or your local python installation). 如果您的应用程序是GAE标准应用程序(
dev_appserver.py
支持的唯一应用程序),则您必须供应应用程序内的所有其他库(GAE不知道/不在乎虚拟环境或本地python安装中安装的库) )。 See python google app engine stripe integration . 请参阅python Google应用程序引擎条带集成 。
Each of the (standard env GAE) examples you're following contains a requirements.txt
with the required libraries - that's the library you need to vendor in, don't just dump the entire example directory in your app and expect the examples to work (as the filepaths in your tracebacks appear to suggest). 您要遵循的每个(标准env GAE)示例都包含带有所需库的
requirements.txt
这是您需要提供的库,不要只是将整个示例目录转储到您的应用中并希望这些示例能够正常工作(如回溯中的文件路径所示)。 They're just independent snippets/examples, not a fully functional, ready-to-use app as a whole. 它们只是独立的摘录/示例,而不是一个功能全面,随时可用的应用程序。 See instructions at https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard
请参阅https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard中的说明
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.