在 python 中为 google 应用引擎生成发现文档时找不到模块

Can't find module when generating discovery docs for google app engine in python

我正在尝试为 iOS 生成 Google App Engine 发现文档,但出现以下错误:

Traceback (most recent call last):


File "/usr/local/google_appengine/endpointscfg.py", line 133, in <module>
    run_file(__file__, globals())
  File "/usr/local/google_appengine/endpointscfg.py", line 129, in run_file
    execfile(_PATHS.script_file(script_name), globals_)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 561, in <module>
    main(sys.argv)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 557, in main
    args.callback(args)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 443, in _GenDiscoveryDocCallback
    application_path=args.application)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 302, in _GenDiscoveryDoc
    application_path=application_path)
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/endpointscfg.py", line 187, in GenApiConfig
    module = __import__(module_name, fromlist=base_service_class_name)
ImportError: No module named default

我是运行下面的命令

/usr/local/google_appengine/endpointscfg.py get_discovery_doc --format roc 
default.rock

此外,以下是我的 app.yaml 文件。所以我正在尝试为我的默认模块生成发现文档。此外,我在名为 rock.py 的文件中有一个名为 RockApi 的云端点 api,所以我的 ServiceClass 应该是什么。像上面一样,我有 default.rock。这是正确的吗?

application: rocky-1191
version: pre-alpha-002
runtime: python27
api_version: 1
threadsafe: yes

'module' 指的是您的 class 所在的 Python 模块,而不是 App Engine 模块。有关示例,请参阅 official docs