运行endpointscfg.py get_swagger_spec时出错

时间:2016-10-07 22:58:05

标签: python google-app-engine google-cloud-platform google-cloud-endpoints google-cloud-sdk

我正在尝试按照本指南使用Google Cloud Endpoints构建项目:Quickstart for Cloud Endpoints Frameworks on App Engine

我遇到了生成OpenAPI配置文件的步骤,我需要运行此命令:

尝试一次

$ lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com

我收到此错误:

-bash: lib/endpoints/endpointscfg.py: Permission denied

尝试两次

我尝试使用sudo的相同命令,该命令返回了此错误:

sudo: lib/endpoints/endpointscfg.py: command not found

尝试三

我尝试cd lib/endpoints从与endpointscfg.py文件相同的文件夹中运行命令:

$ cd lib/endpoints
$ endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com

usage: /Users/myName/google-cloud-sdk/platform/google_appengine/endpointscfg.py
       [-h] {get_client_lib, get_discovery_doc} ...
/Users/myName/google-cloud-sdk/platform/google_appengine/endpointscfg.py: error: argument {get_client_lib, get_discovery_doc}: invalid choice: 'get_swagger_spec' (choose from 'get_client_lib', 'get_discovery_doc')

尝试四

使用python运行它会返回另一种问题:

$ python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com

Traceback (most recent call last):
  File "lib/endpoints/endpointscfg.py", line 59, in <module>
    import _endpointscfg_setup  # pylint: disable=unused-import
  File "/Users/myName/lab/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_setup.py", line 98, in <module>
    _SetupPaths()
  File "/Users/myName/lab/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/_endpointscfg_setup.py", line 94, in _SetupPaths
    from google.appengine.ext import vendor
ImportError: No module named appengine.ext

2 个答案:

答案 0 :(得分:0)

不是直接运行它,而是尝试使用Python运行它,la:

python lib/endpoints/endpointscfg.py get_swagger_spec main.EchoApi --hostname your-service.appspot.com

试过了,这对我有用。我会尝试将其做得更好(通过修复文档或在回购中应用一些修复),但这可能会在过渡期间为您提供所需的内容。

答案 1 :(得分:0)

我遇到了完全相同的问题并尝试了同样的事情。对我有用的是:

chmod +x lib/endpoints/endpointscfg.py

然后再次运行命令。