Error running endpointscfg.py get_swagger_spec

核能气质少年 提交于 2020-02-25 21:46:50

问题


I am trying to build a project using Google Cloud Endpoints, following this guide: Quickstart for Cloud Endpoints Frameworks on App Engine.

I am stuck at the step of generating the OpenAPI configuration file, where I need to run this command:

Attempt One

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

I get this error:

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

Attempt Two

I have tried the same command with sudo, which returned this error:

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

Attempt Three

I have tried to cd lib/endpoints to run the command from the same folder as endpointscfg.py file:

$ 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')

Attempt Four

Running it with python returns a different kind of issue:

$ 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

回答1:


Rather than running it directly, try running it with Python, a la:

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

Tried that and it just worked for me. I'll try and make this better (either by fixing the docs or applying some fix in the repo), but that might get you what you need in the interim.




回答2:


I had the exact same problem and tried the same things. What worked for me was:

chmod +x lib/endpoints/endpointscfg.py

Then running the command again.



来源:https://stackoverflow.com/questions/39926853/error-running-endpointscfg-py-get-swagger-spec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!