Error running endpointscfg.py get_swagger_spec
<p>I am trying to build a project using Google Cloud Endpoints, following this guide: <a href="https://cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python" rel="nofollow">Quickstart for Cloud Endpoints Frameworks on App Engine</a>.</p>

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

<p><strong>Attempt One</strong></p>

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

<p>I get this error:</p>

<pre><code>-bash: lib/endpoints/endpointscfg.py: Permission denied
</code></pre>

<p><strong>Attempt Two</strong></p>

<p>I have tried the same command with <code>sudo</code>, which returned this error:</p>

<pre><code>sudo: lib/endpoints/endpointscfg.py: command not found
</code></pre>

<p><strong>Attempt Three</strong></p>

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

<pre><code>$ 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')
</code></pre>

<p><strong>Attempt Four</strong></p>

<p>Running it with python returns a different kind of issue:</p>

<pre><code>$ 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 &lt;module&gt;
    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 &lt;module&gt;
    _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
</code></pre>

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

<pre><code>chmod +x lib/endpoints/endpointscfg.py
</code></pre>

<p>Then running the command again.</p>

python google-app-engine google-cloud-platform google-cloud-endpoints google-cloud-sdk