在调试模式下本地运行Google App Engine

时间:2018-08-31 02:02:48

标签: google-app-engine

当我尝试在本地以调试模式加载应用程序时,会抛出此错误。

Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
  handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
  handler, path, err = LoadObject(self._handler)
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
  obj = _import_(path[0])
File "/home/ubuntu/Downloads/ndvi-time-series/server.py", line 51, in <module>
  import firebase_admin
File "/home/ubuntu/Downloads/ndvi-time-series/lib/firebase_admin/_init_.py", line 23, in <module>
  from firebase_admin import credentials
File "/home/ubuntu/Downloads/ndvi-time-series/lib/firebase_admin/credentials.py", line 20, in <module>
  import google.auth
File "/usr/lib/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1149, in load_module
  raise ImportError('No module named %s' % fullname)
ImportError: No module named google.auth

我试图找出问题所在,但不知道出了什么问题。

任何人都可以给我一些启发,并帮助我解决问题的方式吗?

谢谢

插件:

在接受了萨米伊斯兰教的评论后,反复提示我对Earthengine进行身份验证,这是在我开始运行'dev_appserver.py app.yaml'之前进行的。

我得到的错误:

ERROR    2018-09-04 06:51:31,938 wsgi.py:263] 
Traceback (most recent call last):
File "/usr/lib/google-cloud- 
sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, 
in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/usr/lib/google-cloud- 
sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, 
in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/usr/lib/google-cloud- 
sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in 
LoadObject
obj = _import_(path[0])
File "/home/ubuntu/Downloads/ndvi-time-series/server.py", line 90, in 
<module>
ee.Initialize()
File "/home/ubuntu/Downloads/ndvi-time-series/lib/ee/_init_.py", line 93, in 
Initialize
credentials = _GetPersistentCredentials()
File "/home/ubuntu/Downloads/ndvi-time-series/lib/ee/_helpers.py", line 40, 
in 
_GetPersistentCredentials
raise EEException('Please authorize access to your Earth Engine account '
EEException: Please authorize access to your Earth Engine account by running

earthengine authenticate

in your command line, and then retry.
INFO     2018-09-04 06:51:31,961 module.py:880] default: "GET / HTTP/1.1" 500 -
INFO     2018-09-04 06:51:32,458 instance.py:294] Instance PID: 31367

1 个答案:

答案 0 :(得分:0)

如果您检查收到的错误消息的结尾,则可以看到以下行“导入错误:没有名为google.auth的模块”。这意味着未找到模块位置的路径。期望google.auth模块和firebase_admin模块位于google包的默认位置。您可以通过在appengine_config.py中提供路径目录来指向调试器查找google包。这样,调试器将能够找到包的位置,并且不会显示ImportError。为了更改查找Google软件包的位置并指向目录,请尝试在appengine_config.py文件中添加以下命令行。

#appengine_config.py
import os
import google
from google.appengine.ext import vendor

lib_directory = os.path.dirname(__file__) + '/lib'

# Change where to find the google package (point to the lib/ directory)
google.__path__ = [os.path.join(lib_directory, 'google')] + google.__path__

# Add any libraries and install it in the "lib" folder.
vendor.add(lib_directory)
相关问题