New Endpoints Python example not working

1,769 views
Skip to first unread message

Zdenko Hrcek

unread,
Sep 5, 2016, 9:48:34 AM9/5/16
to Google Cloud Endpoints
Greetings,

new endpoints & standard GAE. I installed google-endpoints in lib folder. some issues:
1) discovery doesn't work, when I hit http://localhost:8080/_ah/api/explorer there is no api (in Firefox I allowed non secure connections), these are request in logs:
INFO     2016-09-05 10:17:54,792 module.py:788] default: "GET /_ah/api/static/proxy.html?jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.cs.F0XQ_KCCWcc.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Frs%3DAGLTcCPNxvKsgViyWUvbGn1pPwlexiHDjQ HTTP/1.1" 200 8015
INFO     2016-09-05 10:17:54,848 module.py:788] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 404 -
INFO     2016-09-05 10:17:54,848 module.py:788] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60
INFO     2016-09-05 10:17:54,849 module.py:788] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 404 -
INFO     2016-09-05 10:17:54,849 module.py:788] default: "GET /_ah/api/discovery/v1/apis HTTP/1.1" 500 60

2) when I run command python lib/endpoints/endpointscfg.py ...
I get following error:
Traceback (most recent call last):
  File "lib/endpoints/endpointscfg.py", line 615, in <module>
    main(sys.argv)
  File "lib/endpoints/endpointscfg.py", line 611, in main
    args.callback(args)
  File "lib/endpoints/endpointscfg.py", line 479, in _GenSwaggerSpecCallback
    application_path=args.application)
  File "lib/endpoints/endpointscfg.py", line 324, in _GenSwaggerSpec
    application_path=application_path)
  File "lib/endpoints/endpointscfg.py", line 181, in GenApiConfig
    module = __import__(module_name, fromlist=base_service_class_name)
  File "/home/zdenulo/dev/test/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/main.py", line 19, in <module>
    import endpoints
  File "/home/zdenulo/dev/test/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/__init__.py", line 29, in <module>
    from apiserving import *
  File "/home/zdenulo/dev/test/python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo/lib/endpoints/apiserving.py", line 72, in <module>
    from google.api.control import client as control_client
ImportError: No module named api.control

First I thought what I have messed up paths or something like that, but I did everything on clean VM, installed Google Cloud SDK, example and still same errors.

Just asking if somebody had experience running this example, i.e. if it's working or not, or at best how to fix these errors :)

Zdenko

Dan Ciruli

unread,
Sep 8, 2016, 7:01:18 PM9/8/16
to Google Cloud Endpoints

Zdenko -- we are looking into the problem and will update this as soon as we have found what happened!

Thanks for pointing it out.

Dan

Jason Allor

unread,
Sep 9, 2016, 12:10:48 PM9/9/16
to Dan Ciruli, Sai Cheemalapati, Google Cloud Endpoints
Hi Zdenko. We have identified the cause of the issue and are working on fixing the sample. Thanks again for bringing this to our attention.

From the dev who tracked down the issue:

The fix is to setup google.api as namespace packages, so:
Add an __init__.py to lib/google and lib/google/api

The content of the __init__.py s should be:

__import__('pkg_resources').declare_namespace(__name__)

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/ccfedf25-6111-455d-ae4e-9c8dcaeed2a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

dynamo...@gmail.com

unread,
Oct 7, 2016, 3:06:47 PM10/7/16
to Google Cloud Endpoints, cir...@google.com, saic...@google.com
I can confirm this bug still exists as of today on a clean installation of the Cloud SDK using the endpoints v2 "echo" test app.  The exact same error occurs on the deployed app as well.

Unfortunately the fix mentioned by the developer does not work.  After two days of struggling to get Endpoints v2 working, I'm hoping someone has stumbled across a solution.

Best,
Brian

Jason Allor

unread,
Oct 7, 2016, 4:07:38 PM10/7/16
to dynamo...@gmail.com, Brad Friedman, D. T., Google Cloud Endpoints, Dan Ciruli, Sai Cheemalapati
Hi Brian. I'm sorry to hear that you're still struggling with this issue. Just to check, when you indicate "a client install of the Cloud SDK," have you also clean-installed the Endpoints sample? We did upload a new version of the sample to GitHub on Sept 13, which at the time we did believe fixed the issue.

If you can confirm that you are indeed using the latest sample, would you mind copying the exact error result you're seeing and sending it to us? We will prioritize investigating this and want to make sure we have the latest correct debugging information.

Thank you.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

dynamo...@gmail.com

unread,
Oct 7, 2016, 4:30:51 PM10/7/16
to Google Cloud Endpoints, dynamo...@gmail.com, frie...@google.com, D. T., cir...@google.com, saic...@google.com
Just as I was about to attempt to revert back to Endpoints v1, you responded!  Thank you!  

Yes, I completely uninstalled both the Cloud SDK and a previously installed standalone App Engine SDK and reinstalled only the latest Cloud SDK.  Here's additional information about my environment:

Windows 10 64bit
Python 2.7.9
Google Cloud SDK 129.0.0
app-engine-python 1.9.40
google-endpoints 2.0.0b3
beta 2016.01.12
bq 2.0.24
bq-win 2.0.24
bundled-python 2.7.10
core 2016.10.04
core-win 2016.08.05
gcloud
gsutil 4.21
gsutil-win 4.20
powershell 0.1.7
windows-ssh-tools 2016.05.13

python-doc-samples commit 02f7e56 (October 6, 2016)

I followed the instructions letter for letter here:

There are no problems until I attempt to send a test request, and the response is exactly as above with the response being:
{
  "error": {
    "message": "BackendService.getApiConfigs Error"
  }
}

And the logs showing:
F:\Projects\python-docs-samples\appengine\standard\endpoints-frameworks-v2\echo>dev_appserver.py .
INFO     2016-10-07 15:23:39,683 sdk_update_checker.py:229] Checking for updates to the SDK.
INFO     2016-10-07 15:23:41,030 sdk_update_checker.py:257] The SDK is up to date.
INFO     2016-10-07 15:23:41,371 api_server.py:205] Starting API server at: http://localhost:1029
INFO     2016-10-07 15:23:41,388 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2016-10-07 15:23:41,394 admin_server.py:116] Starting admin server at: http://localhost:8000
INFO     2016-10-07 15:24:19,522 module.py:788] default: "POST /_ah/spi/BackendService.getApiConfigs HTTP/1.1" 404 -
INFO     2016-10-07 15:24:19,526 module.py:788] default: "POST /_ah/api/echo/v1/echo HTTP/1.1" 500 60


Adding the recommended __init__.py files as described didn't make any change and deploying it results in the same error.


Best,
Brian

Brad Friedman

unread,
Oct 7, 2016, 4:39:41 PM10/7/16
to dynamo...@gmail.com, Google Cloud Endpoints, D. T., Dan Ciruli, Sai Cheemalapati
Hey Brian, thanks for these details! Testing Endpoints Frameworks v2 apps locally (using dev_appserver.py) is not yet supported in beta. Does your app work when you deploy it to App Engine?

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsubscri...@googlegroups.com.

prom...@gmail.com

unread,
Oct 19, 2016, 6:44:52 PM10/19/16
to Google Cloud Endpoints, dynamo...@gmail.com, D. T., cir...@google.com, saic...@google.com, frie...@google.com
Hello

Any update or workaround about getting this working locally without deploying to App Engine?

Thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

D. T.

unread,
Oct 19, 2016, 7:47:47 PM10/19/16
to prom...@gmail.com, Google Cloud Endpoints, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com
Unfortunately, due to delays in the release of the App Engine Python SDK, this still isn't available.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

Vidy

unread,
Jan 12, 2017, 5:33:06 AM1/12/17
to Google Cloud Endpoints, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com
Is there an update to this ? Is it possible to test cloud endpoints v2 locally without deploying to the server ?

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

D. T.

unread,
Jan 13, 2017, 1:43:38 PM1/13/17
to Vidy, Google Cloud Endpoints, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com
Yes, if you update gcloud it should work now. Apologies for the delay.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/edcf1cf7-f37e-44d3-b15f-2e2fa0a8c624%40googlegroups.com.

tdi...@gmail.com

unread,
Jan 15, 2017, 1:41:38 AM1/15/17
to Google Cloud Endpoints, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com
Hi , I am a newbie to the cloud and followed the echo example. I am getting

HTML>

<HEAD>

<TITLE>Internal Server Error</TITLE>

</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000">

<H1>Internal Server Error</H1>

<H2>Error 500</H2>

</BODY>

</HTML>


thanks. T.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

Jack Woodward

unread,
Jan 21, 2017, 8:21:34 AM1/21/17
to Google Cloud Endpoints, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
Hey, I am also getting this error aswell. I have done a clean install of gcloud and ran through the quickstart 3 times but everytime i get the Error 500 when doing the upload. When I run it locally using dev_appserver it works. Any help would be great as otherwise I will have to use V1.

D. T.

unread,
Jan 21, 2017, 12:13:18 PM1/21/17
to Jack Woodward, Google Cloud Endpoints, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
By "doing the upload" you mean when deploying your app? Can you show logs from the command line and from the app?

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/07cec034-d5d4-40d9-a3b9-c62b79ee03e7%40googlegroups.com.

vento...@gmail.com

unread,
Jan 21, 2017, 6:58:48 PM1/21/17
to Google Cloud Endpoints, jackwoo...@gmail.com, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
Same html error 500 for me when deploying the quickstart app. I did it twice after a clean install of gcloud. Curl api requests fail and [project-id].appspot.com link also.
Thanks.
Message has been deleted

vento...@gmail.com

unread,
Jan 22, 2017, 4:11:49 AM1/22/17
to Google Cloud Endpoints, vento...@gmail.com, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
It doesn't work for me.
In my case an App Engine default service account was already existing as an editor. 

vento...@gmail.com

unread,
Jan 24, 2017, 12:11:13 PM1/24/17
to Google Cloud Endpoints, vento...@gmail.com, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
I changed quickstart app for echo app and it works.
Maybe is there something wrong in the quickstart.

D. T.

unread,
Jan 24, 2017, 4:46:35 PM1/24/17
to vento...@gmail.com, Google Cloud Endpoints, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
Could you please specify what you changed so we know what we need to do to update our docs?

Thanks!
Daniel

On Tue, Jan 24, 2017 at 9:11 AM <vento...@gmail.com> wrote:
I changed quickstart app for echo app and it works.
Maybe is there something wrong in the quickstart.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

vento...@gmail.com

unread,
Jan 27, 2017, 2:39:20 PM1/27/17
to Google Cloud Endpoints, vento...@gmail.com, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
I changed nothing at all. I only used the echo example instead of the quikstart one.


Le mardi 24 janvier 2017 22:46:35 UTC+1, Daniel Tang a écrit :
Could you please specify what you changed so we know what we need to do to update our docs?

Thanks!
Daniel

On Tue, Jan 24, 2017 at 9:11 AM <vento...@gmail.com> wrote:
I changed quickstart app for echo app and it works.
Maybe is there something wrong in the quickstart.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

cm...@connektinc.com

unread,
Feb 24, 2017, 6:08:04 PM2/24/17
to Google Cloud Endpoints, vidy...@gmail.com, prom...@gmail.com, dynamo...@gmail.com, cir...@google.com, saic...@google.com, frie...@google.com, tdi...@gmail.com
Hi,

I'm getting same error using the

python-docs-samples/appengine/standard/endpoints-frameworks-v2/echo


After I deploy it and run the curl post command, I get the following in the logs:


Traceback (most recent call last): File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 240, in Handle handler = _config_handle.add_wsgi_middleware(self._LoadHandler()) File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 299, in _LoadHandlerhandler, path, err = LoadObject(self._handler) File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 85, in LoadObject obj = __import__(path[0]) File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/main.py", line 103, in <module> api = endpoints.api_server([EchoApi]) File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/lib/endpoints/apiserving.py", line 514, in api_server controller) File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/lib/google/api/control/wsgi.py", line 121, in add_all a_service = loader.load() File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/lib/google/api/control/service.py", line 110, in load return self._load_func(**kw) File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/lib/google/api/config/service_config.py", line 78, in fetch_service_config _log_and_raise(Exception, message_template.format(status_code)) File "/base/data/home/apps/s~dev-connectinc/20170224t134902.399423748272302684/lib/google/api/config/service_config.py", line 126, in _log_and_raise raise exception_class(message) Exception: Fetching service config failed (status code 403)

request_id: "58b0a0c500ff0d7bfc2184ef4e0001737e6465762d636f6e6e656374696e630001323031373032323474313334393032000100" 
timestamp: "2017-02-24T21:08:21.998Z" 
location: "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:263"

dmitry....@gmail.com

unread,
Mar 6, 2017, 2:32:47 PM3/6/17
to Google Cloud Endpoints
I get this error when trying to run the setup configured by buildout when endpoints and all it's dependencies are installed as eggs. If I install endpoints with pip into local lib/ directory everything works fine and I can launch the app.
Maybe someone has an idea why buildout/eggs-based setup refuses to work?
The versions I use:
* google_endpoints-2.0.3-py2.7.egg
* google_endpoints_api_management-1.0.1-py2.7.egg
* google_appengine_1.9.50

Brad Friedman

unread,
Mar 6, 2017, 3:44:36 PM3/6/17
to dmitry....@gmail.com, Google Cloud Endpoints
Which error are you getting specifically? Do you get it when running endpointscfg.py or when trying to hit your service?

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

dmitry....@gmail.com

unread,
Mar 6, 2017, 4:33:52 PM3/6/17
to Google Cloud Endpoints, dmitry....@gmail.com
Here is what I'm doing in details.
* I use buildout configuration to setup project locally, hence endpoints package and all it's dependencies are installed as eggs under eggs/ directory.
* The google_appengine_1.9.50 SDK is downloaded and unpacked under parts/google_appengine
*  To make the app aware of all the libraries installed as eggs I have the following code in my appengine_config.py file:
import os
import sys

lib_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'eggs')
if os.path.isdir(lib_dir):
    for lib in os.listdir(lib_dir):
        if lib.endswith('.egg'):
            lib = os.path.join(lib_dir, lib)
            sys.path.insert(0, lib) 

* I can launch the app locally with dev_appserver no problems.
* The moment I send a request to the app, it fails with the following error:
ERROR    2017-03-06 20:54:05,453 wsgi.py:263]
Traceback (most recent call last):
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "SOMEPATH/main.py", line 6, in <module>
    import endpoints
  File "SOMEPATH/eggs/google_endpoints-2.0.3-py2.7.egg/endpoints/__init__.py", line 29, in <module>
    from apiserving import *
  File "SOMEPATH/eggs/google_endpoints-2.0.3-py2.7.egg/endpoints/apiserving.py", line 74, in <module>
    from google.api.control import client as control_client
ImportError: No module named api.control

I suspect the problem is related to the fact that the packages are installed as eggs, something doesn't work with namespace packages in that case. If I install everything with pip into local lib/ directory and then include it with vendor.add('lib') in the appengine_config.py file everything seems to be working fine.
But my question is if I can make it work with eggs as this is how buildout installs everything?

Brad Friedman

unread,
Mar 6, 2017, 5:59:24 PM3/6/17
to dmitry....@gmail.com, Google Cloud Endpoints
Thanks for the reply! In an interactive Python session, can you import the google module from the Endpoints management package and then print out the module's __path__ and/or __file__ attributes? Does it look like it's coming from the expected location? I'm wondering whether it's importing from someplace else on your path.

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsubscri...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

dmitry....@gmail.com

unread,
Mar 7, 2017, 5:55:52 AM3/7/17
to Google Cloud Endpoints, dmitry....@gmail.com
Thanks a lot for trying to help Brad!
To my huge surprise I found out that importing google.api.control module works in interactive python session! Below is the output:
In [1]: import google

In [2]: print google.__file__
SOMEPATH/parts/google_appengine/google/__init__.pyc

In [3]: print google.__path__
['SOMEPATH/eggs/google_endpoints_api_management-1.0.1-py2.7.egg/google', 'SOMEPATH/parts/google_appengine/google']

In [4]: import google.api.control

In [5]: print google.api.control
<module 'google.api.control' from 'SOMEPATH/eggs/google_endpoints_api_management-1.0.1-py2.7.egg/google/api/control/__init__.pyc'>

But when I print google.__file__ and google.__path__ from the main.py I see the following:
INFO     2017-03-07 10:13:12,138 module.py:806] default: "GET /_ah/start HTTP/1.1" 404 -
SOMEPATH/eggs/pycrypto-2.6.1-py2.7-linux-x86_64.egg
SOMEPATH/eggs/oauth2client-1.5.2-py2.7.egg
SOMEPATH/eggs/setuptools-33.1.1-py2.7.egg
SOMEPATH/eggs/zc.buildout-2.9.2-py2.7.egg
SOMEPATH/eggs/enum34-1.1.6-py2.7.egg
SOMEPATH/eggs/ply-3.10-py2.7.egg
SOMEPATH/eggs/zc.recipe.egg-2.0.3-py2.7.egg
SOMEPATH/eggs/six-1.10.0-py2.7.egg
SOMEPATH/eggs/pyasn1_modules-0.0.8-py2.7.egg
SOMEPATH/eggs/dogpile.cache-0.6.2-py2.7.egg
SOMEPATH/eggs/cachetools-1.1.6-py2.7.egg
SOMEPATH/eggs/strict_rfc3339-0.7-py2.7.egg
SOMEPATH/eggs/future-0.16.0-py2.7.egg
SOMEPATH/eggs/pyjwkest-1.0.9-py2.7.egg
SOMEPATH/eggs/urllib3-1.20-py2.7.egg
SOMEPATH/eggs/rsa-3.4.2-py2.7.egg
SOMEPATH/eggs/pylru-1.0.9-py2.7.egg
SOMEPATH/eggs/requests-2.13.0-py2.7.egg
SOMEPATH/eggs/google_endpoints-2.0.3-py2.7.egg
SOMEPATH/eggs/pyasn1-0.2.3-py2.7.egg
SOMEPATH/eggs/google_endpoints_api_management-1.0.1-py2.7.egg
SOMEPATH/eggs/ipython-2.3.1-py2.7.egg
SOMEPATH/eggs/mr.developer-1.37-py2.7.egg
SOMEPATH/eggs/google_apitools-0.4.15-py2.7.egg
SOMEPATH/eggs/httplib2-0.10.3-py2.7.egg
SOMEPATH/
SOMEPATH/parts/google_appengine
SOMEPATH/parts/google_appengine
/home/dima/work/localpython/lib/python2.7
/home/dima/work/localpython/lib/python2.7/lib-dynload
SOMEPATH/parts/google_appengine/lib/pycrypto-2.6
SOMEPATH/parts/google_appengine/lib/ssl-2.7.11
SOMEPATH/parts/google_appengine/lib/grpcio-1.0.0
SOMEPATH/parts/google_appengine/lib/protorpc-1.0
SOMEPATH/parts/google_appengine/lib/pytz-2016.4
SOMEPATH/parts/google_appengine/lib/webapp2-2.3
SOMEPATH/parts/google_appengine/lib/webob-1.1.1
SOMEPATH/parts/google_appengine/lib/werkzeug-0.11.10
SOMEPATH/parts/google_appengine/lib/yaml-3.10
GOOGLE: SOMEPATH/parts/google_appengine/google/__init__.pyc
GOOGLE: ['SOMEPATH/parts/google_appengine/google']
ERROR    2017-03-07 10:13:12,152 wsgi.py:263] 
Traceback (most recent call last):
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
    handler, path, err = LoadObject(self._handler)
  File "SOMEPATH/parts/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
    obj = __import__(path[0])
  File "SOMEPATH/main.py", line 10, in <module>
    import google.api
ImportError: No module named api
INFO     2017-03-07 10:13:12,164 module.py:806] default: "POST /_ah/api/echo/v1/echo?n=2 HTTP/1.1" 500 -

I printed sys.path first to make sure that google_endpoints_api_management package is included into it. And then you can see two lines with GOOGLE: prefix, these are:
import google
print "GOOGLE:", google.__file__
print "GOOGLE:", google.__path__

And I can see that in contrast to the interactive session the google.__path__ includes only SDK path but not google_endpoints_api_management-1.0.1-py2.7.egg. This is really weird and I don't know how to explain this...
Could it be related to the way different versions of setuptools manage namespace packages? The setuptools package which is available with python is pretty old: setuptools-0.6c11 (we stick to that version because this is what available in the appengine), the new one is available under eggs/setuptools-33.1.1-py2.7.egg but I'm not sure which one is loaded first and if it could be a problem at all.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endpoints+unsub...@googlegroups.com.

dmitry....@gmail.com

unread,
Mar 9, 2017, 9:28:01 AM3/9/17
to Google Cloud Endpoints, dmitry....@gmail.com
I'll just leave a comment here how I made stuff work in my case, maybe someone finds it helpful.

What fixed the "ImportError: No module named api.control" problem for me is importing pkg_resources module in the appengine_config.py file. I know that sounds strange but "import pkg_resources" forced the pkg_resources module from eggs/setuptools-33.1.1-py2.7.egg to be loaded and used instead of whatever was used by default.

One other situation where I encountered exactly the same problem was when I tried to copy all package sources (packages which are installed as dependencies for google-endpoints) into a separate directory. I'm doing that to minimize the amount of data I need to copy into the cloud when deploying the application. But that doesn't work in case of google-endpoints-api-management package, I think the reason is that pkg_resources needs the meta information which is available in the EGG-INFO directory (or dist-info when installing with pip) to correctly fix namespaces. So in case of google-endpoints-api-management package, when deploying, I'm copying the full egg content in contrast to other packages where I copy only the sources skipping all the meta data, tests etc.

Akash Singh

unread,
Mar 20, 2017, 3:39:47 AM3/20/17
to Google Cloud Endpoints, dmitry....@gmail.com
Dude this worked for me, nothing else worked, this was life saviour, thanks a lot

pe...@getople.com

unread,
Apr 10, 2017, 9:04:38 PM4/10/17
to Google Cloud Endpoints, dmitry....@gmail.com
Tried this fix. Didn't work for me!  Still having the same issue. Anyone still having those problems or it is only me?

D. T.

unread,
Apr 11, 2017, 1:22:34 PM4/11/17
to pe...@getople.com, Google Cloud Endpoints, dmitry....@gmail.com
This thread is quite old and actually spanning many issues now. Can you please start a new thread with the details of the issue you're having?

To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Endpoints" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-endp...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-endpoints/8a3fb3ec-00e8-4138-aa72-e7cd7dc9af15%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages