错误 运行 endpointscfg.py get_swagger_spec

Error running endpointscfg.py get_swagger_spec

我正在尝试使用 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 returns 不同类型的问题:

$ 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

与其直接 运行,不如尝试 运行 和 Python,啦:

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

试过了,它对我有用。我会尝试让它变得更好(通过修复文档或在回购中应用一些修复),但这可能会让你在过渡期间得到你需要的东西。

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

chmod +x lib/endpoints/endpointscfg.py

然后运行再次执行命令。