2

After trying to get Google App Engine working locally, I think it's best to ask this question here, and answer it myself. I'm sure some of you might be having this problem.

After installing the GAE SDK for Python, I tried running the tutorial. I cloned their 'Hello World' app from GitHub, and tried to run it locally using dev_appserver.py. I kept getting an error message saying "No module named appengine.api"

I use TensorFlow, and a few packages developed by Google, and found a way to get around this. I will answer below.

mtisz
  • 1,000
  • 10
  • 11

2 Answers2

1

What happened to me was there were a few libraries developed by Google already added to my PYTHONPATH. So when dev_appserver.py was trying execute the following line,

from google.appengine.api import appinfo

it was throwing an error saying "ImportError: No module named appengine.api" because it was already looking at a different google module. In my case this was caused by Protobuf. I tried to figure out a way to keep Protobuf but the time got to me, and I didn't want to waste any more time. You can run

pip list

and see whether you have this module installed. What I did was then uninstall it using

sudo pip uninstall protobuf

This uninstalls the already added packages to the PYTHONPATH, namely

/usr/local/lib/python2.7/site-packages/google/

Which is the Google path that created the issue. Now, to be safe, if you run

export PYTHONPATH="$PYTHONPATH:/usr/local/google_appengine"

it should take care of the dev_appserver.py import modules and it should run.

Please comment, or let me know if you figure out a new way of doing this.

mtisz
  • 1,000
  • 10
  • 11
0

Update: the issue was fixed in SDK version 1.9.40.

This is likely caused by GAE Issue 12963, which still affects the current (1.9.38) SDK version. See "ImportError: No module named webapp2" after Linux SDK upgrade (1.9.35 -> 1.9.38)

If your SDK version is 1.9.37 or 1.9.38 downgrade to 1.9.36, which you can find here. At least until the fix gets released. This allows you to not manually fiddle with the PYTHONPATH which might cause you trouble down the road.

Community
  • 1
  • 1
Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97