GAE Python / OSX, version 1.9.37: ImportError: No module named appengine.api

2,675 views
Skip to first unread message

Matti Dahlbom

unread,
May 20, 2016, 12:36:04 PM5/20/16
to Google App Engine
When running dev_appserver.py after updating to the latest (1.9.37) GAE Python SDK I am getting the following error:

[matti@babylon appengine-server] 19:22:06 % /usr/local/bin/dev_appserver.py .

 

Traceback (most recent call last):

 
File "/usr/local/bin/dev_appserver.py", line 84, in <module>

    _run_file
(__file__, globals())

 
File "/usr/local/bin/dev_appserver.py", line 80, in _run_file

    execfile
(_PATHS.script_file(script_name), globals_)

 
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 31, in <module>

   
from google.appengine.api import appinfo

ImportError: No module named appengine.api


I checked and everything seems to be in order in /usr/local/google_appengine/. I even tried adding that to my PYTHONPATH, to no avail. I've used probably 30+ versions of GAE - updating in a similar manner every time - and have never seen it break like this.

Someone else is having the same problem over at SO:

http://stackoverflow.com/questions/37236748/importerror-no-module-named-appengine-api

BR, 

- Matti

Anastasios Hatzis

unread,
May 20, 2016, 4:52:20 PM5/20/16
to google-a...@googlegroups.com
I have added two comments. Updated today to this version on OS X 10.11.4 and after updating the symlinks (in GoogleAppEngineLauncher menu), I could launch the app. Later I also launched from CLI (dev_appserver.py), but only after I was prompted to update a gcloud component.

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/be728fb8-0c73-4f7d-9201-b0b692047049%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Mit freundlichen Grüßen / Kind regards

i. A.
Anastasios Hatzis

Fon: +49 8374 930813
Fax: +49 8374 930810
Mobil: +49 1520 8592878

HATZIS Edelstahlbearbeitung GmbH
Hojen 2
87490 Haldenwang (Allgäu)
Germany

Handelsregister Kempten (Allgäu): HRB 4204
Geschäftsführer: Paulos Hatzis, Charalampos Hatzis
Umsatzsteuer-Identifikationsnummer: DE 128791802
GLN: 42 504331 0000 6

http://www.hatzis.de/

Matti Dahlbom

unread,
May 21, 2016, 1:38:28 AM5/21/16
to Google App Engine


On Friday, May 20, 2016 at 11:52:20 PM UTC+3, Anastasios Hatzis wrote:
I have added two comments. Updated today to this version on OS X 10.11.4 and after updating the symlinks (in GoogleAppEngineLauncher menu), I could launch the app. Later I also launched from CLI (dev_appserver.py), but only after I was prompted to update a gcloud component

I believe you've been using dev_appserver.py that ships with the gcloud SDK instead of the one that ships with GAE SDK. 

- Matti 

Adam (Cloud Platform Support)

unread,
May 23, 2016, 6:07:56 PM5/23/16
to Google App Engine
It would be interesting to see what the results are if you throw in a few debug statements above line 31 in 'devappserver2.py':

import google
print(google)
print(sys.path)

I've tried to break this on my machine by introducing a 'google' module in my sys.path, but I cannot reproduce it.

Matti Dahlbom

unread,
May 24, 2016, 2:06:49 AM5/24/16
to Google App Engine


On Tuesday, May 24, 2016 at 1:07:56 AM UTC+3, Adam (Cloud Platform Support) wrote:
It would be interesting to see what the results are if you throw in a few debug statements above line 31 in 'devappserver2.py':

import google
print(google)
print(sys.path)


It prints: 

<module 'google' from '/usr/local/bin/google'>


['/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/antlr3', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/fancy_urllib', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/ipaddr', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/yaml-3.10', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/rsa', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/pyasn1', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/pyasn1_modules', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/httplib2', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/oauth2client', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/six', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/concurrent', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/portpicker', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/jinja2-2.6', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webob-1.2.3', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2-2.5.1', '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine', '/Library/Python/2.7/site-packages/six-1.10.0-py2.7.egg', '/Users/matti/src/vision-api-poc/appengine-server', '/usr/local/google_appengine', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages']


Traceback (most recent call last):


  File "/usr/local/bin/dev_appserver.py", line 84, in <module>


    _run_file(__file__, globals())


  File "/usr/local/bin/dev_appserver.py", line 80, in _run_file


    execfile(_PATHS.script_file(script_name), globals_)


  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 35, in <module>


    from google.appengine.api import appinfo


ImportError: No module named appengine.api


 Just for clarification, I have both gcloud SDK as well as GAE SDK installed. I'm using GAE SDK since the gcloud one does not have Django (or other libs apparently). I'm running the dev_appserver with the following shelll script:

# Set GOOGLE_APPLICATION_CREDENTIALS so that the service account key file

# can be found by the Google APIs, ie:

#

# export GOOGLE_APPLICATION_CREDENTIALS="/path/to/file.json"


if [ -z ${GOOGLE_APPLICATION_CREDENTIALS+x} ]; then

    echo "You must set GOOGLE_APPLICATION_CREDENTIALS!";

   exit 1

fi


/usr/local/bin/dev_appserver.py --host=0.0.0.0 .


- Matti

Adam (Cloud Platform Support)

unread,
May 24, 2016, 1:12:47 PM5/24/16
to Google App Engine
It looks like you also have the 'google' package (Python bindings to the Google search engine) installed eg. via pip or homebrew, which will install a module in '/usr/local/bin/google', and it's getting imported instead of '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google'.

As for why, something tells me it's related to this recently reported issue, in which it appears dev_appserver is changing the way the 'google' import is added to sys.modules. As a workaround, you can try uninstalling or renaming '/usr/local/bin/google' to something else and see if the problem goes away.

Matti Dahlbom

unread,
May 25, 2016, 2:46:40 AM5/25/16
to Google App Engine


On Tuesday, May 24, 2016 at 8:12:47 PM UTC+3, Adam (Cloud Platform Support) wrote:
It looks like you also have the 'google' package (Python bindings to the Google search engine) installed eg. via pip or homebrew, which will install a module in '/usr/local/bin/google', and it's getting imported instead of '/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google'.

As for why, something tells me it's related to this recently reported issue, in which it appears dev_appserver is changing the way the 'google' import is added to sys.modules. As a workaround, you can try uninstalling or renaming '/usr/local/bin/google' to something else and see if the problem goes away.


Hmm. I don't see a package like that in 'pip list' nor 'brew list' nor can I remember installing it ever. Also, there is no '/usr/local/bin/google' on my system. I do have '/usr/local/bin/google_sql.py' but that's the only google* thingy in that directory. 

- Matti 

Matti Dahlbom

unread,
May 25, 2016, 2:51:59 AM5/25/16
to Google App Engine


As for why, something tells me it's related to this recently reported issue, in which it appears dev_appserver is changing the way the 'google' import is added to sys.modules. As a workaround, you can try uninstalling or renaming '/usr/local/bin/google' to something else and see if the problem goes away.


Aah, grepping from that issue you mentioned: 

Looking around using pdb, I was able to pinpoint the problem to a conflict with the python2-protobuf archlinux package providing a built-in google module that seem to upset the new code.

I indeed have the protobuf packages installed also.

- Matti

Reply all
Reply to author
Forward
0 new messages