ImportError: No module named webapp2

2,468 views
Skip to first unread message

Ted Roden

unread,
May 9, 2016, 4:23:45 PM5/9/16
to Google App Engine
I just upgraded to 1.9.37 and now when I start the app I'm getting this error:

> ImportError: No module named webapp2

Nothing else has changed. 

I thought perhaps Google stopped bundling it, so I did a "pip install webapp2," but that didn't help (I've since removed that). 

Any ideas on what's going on?

Nick (Cloud Platform Support)

unread,
May 11, 2016, 4:07:11 PM5/11/16
to Google App Engine
Hey Ted,

This sounds like an issue which would be better posted to a forum designed for specific-issue technical support such as Stack Overflow. However, before doing so, you should be sure to gather enough information that the people on the other end of the internet will be able to adequately begin thinking about the issue. For example, you might want to include the following information:

* Is this happening in production or the development environment?

* What is the full stack trace? 

* If it's in development, how are you running the project?

You can feel free to reply either here or on Stack Overflow but I recommend posting to Stack Overflow for the reason that there are many more users there who can potentially assist with an issue like this.

Cheers,

Nick
Cloud Platform Community Support
Message has been deleted

Anand Atreya

unread,
May 18, 2016, 4:33:13 PM5/18/16
to Google App Engine
It looks like the protobuf pip package conflicts with webapp2. I temporarily resolved the issue by uninstalling all google python packages (gcloud, protobuf, googleapis-common-protos) which allows webapp2 to work again. Reinstalling protobuf breaks it. Unfortunately I need webapp2 to work while protobuf is installed.

This seems like an issue that Google should address - can you look into it?

Jon Parrott

unread,
May 19, 2016, 2:58:45 PM5/19/16
to Google App Engine
Can you provide us with a simple reproducible case? a github repo or gist would be easiest.

Nick (Cloud Platform Support)

unread,
May 19, 2016, 5:54:58 PM5/19/16
to Google App Engine
Seconding Jon here - if you can upload a minimal reproducing example of your app along with some system information such as installed pip packages, the PYTHONPATH environment variable, printing sys.path in the code of your app, etc., it would massively aid in being able to determine the root cause.

Thanks!


Nick
Cloud Platform Community Support

Anand Atreya

unread,
May 20, 2016, 3:27:54 PM5/20/16
to Google App Engine
I can't upload a minimal version of the app right now, but I did some poking around since the problem occurred in 1.9.37 and doesn't occur in 1.9.34, and the problem appears to be due to this change in _python_runtime.py:

$ diff 1.9.37/_python_runtime.py 1.9.34/_python_runtime.py 

72,75d71

<   if 'google' in sys.modules:

<     google_path = os.path.join(os.path.dirname(__file__), 'google')

<     google_module = sys.modules['google']

<     google_module.__path__.append(google_path)

78c74,77

<     google_module.__file__ = google_path

---

>   if 'google' in sys.modules:

>     del sys.modules['google']


If I copy the old version of this file over the new one, the error goes away. The relevant pip packages that I have installed are gcloud (0.14.0), googleapis-common-protos (1.1.0), protobuf (3.0.0b3). Again, if I uninstall these, the problem also goes away. PYTHONPATH is empty.


The differences in sys.path (printed just before the failing webapp2 import statement) are:

Working: [..., '/Users/aatreya/1.9.34/lib/pycrypto-2.6', '/Users/aatreya/1.9.34/lib/webapp2-2.5.2', '/Users/aatreya/1.9.34/lib/protorpc-1.0', '/Users/aatreya/1.9.34/lib/webob-1.1.1', '/Users/aatreya/1.9.34/lib/yaml-3.10']

Not working: [..., '/Users/aatreya/lib/pycrypto-2.6', '/Users/aatreya/lib/webapp2-2.5.2', '/Users/aatreya/lib/protorpc-1.0', '/Users/aatreya/lib/webob-1.1.1', '/Users/aatreya/lib/yaml-3.10']

Note that /Users/aatreya/lib does not exist.

Let me know if this helps.
Anand

Nick (Cloud Platform Support)

unread,
May 20, 2016, 4:26:43 PM5/20/16
to Google App Engine
Thanks for the detailed reply. 

I'll forward this information to the SDK developers and see if they can make use of the report. For your case, I'd recommend installing python packages to a folder in your app, not system-wide, via "pip -t install", or virtualenv, as this may resolve the issue of not being able to find system-level modules due to the way the SDK is altering the path. Let me know if that works out or not in the meantime.


Cheers,

Nick
Cloud Platform Community Support

Stephen Cagle

unread,
May 25, 2016, 12:45:36 PM5/25/16
to Google App Engine
I just want to second that I also had a conflict with googleapis-common-proto which I had to `pip uninstall` in order to get webapp2 to show up.

Jon Parrott

unread,
May 25, 2016, 12:49:03 PM5/25/16
to Google App Engine
Thanks for chiming in, Stephen. If you can provide a simple case where you can reproduce this, that would be really helpful in us figuring out why this is occurring.

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/LucknWk8iaQ/unsubscribe.
To unsubscribe from this group and all its topics, 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/df8c5421-a84a-44fe-bf63-8497ad7eed18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Matthieu Rouget

unread,
May 26, 2016, 10:38:03 AM5/26/16
to Google App Engine
Hello all,

Same issue for me.

I use the dev_appserver.py that comes wich gcloud (app-engine-python 1.9.37) on an Ubuntu 14.04 LTS.
The application I use is the "helloworld" straight from the AppEngine Python QuickStart (https://cloud.google.com/appengine/docs/python/quickstart).
With the protobuf python package installed (through pip), I get an error at import webapp2.
If I uninstall protobuf with pip, everything works as expected.


Jon Parrott

unread,
May 26, 2016, 1:17:29 PM5/26/16
to Google App Engine
Thanks everyone for reporting this. We've reproduced the issue and and fix is incoming. It won't be in the next SDK release (38), but likely will be in 39 or 40.

Michael Nadel

unread,
Jun 1, 2016, 2:47:18 PM6/1/16
to Google App Engine
Thanks Jon. Is there an issue for this on http://code.google.com?

Jon Parrott

unread,
Jun 1, 2016, 3:37:05 PM6/1/16
to Google App Engine
I do not think so.

--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/LucknWk8iaQ/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Dennis van Velzen

unread,
Jun 22, 2016, 1:54:00 PM6/22/16
to Google App Engine
My first introduction with GAE started with webapp2 module import error.

I (also) needed to uninstall 3 modules.

sudo pip uninstall gcloud
sudo pip uninstall googleapis-common-protos
sudo pip uninstall protobuf



Op maandag 9 mei 2016 22:23:45 UTC+2 schreef Ted Roden:

Josh Moore

unread,
Jun 22, 2016, 2:21:38 PM6/22/16
to google-a...@googlegroups.com
There is actually a public issue for this behavior: https://code.google.com/p/googleappengine/issues/detail?id=12963
Do feel free to star the issue for updates.

--
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.

For more options, visit https://groups.google.com/d/optout.



--

Josh Moore | Cloud Solutions Engineer | josh...@google.com | 

Huang-Wei Chang

unread,
Jul 15, 2016, 5:12:34 PM7/15/16
to Google App Engine
I am wondering is there any update? I tried version 38 and it indeed doesn't work. It's really frustrating for not being able to try even the hello_world example.

Jon Parrott

unread,
Jul 15, 2016, 5:34:25 PM7/15/16
to Google App Engine
The fix for this will be in the next App Engine SDK release (1.9.40). In the meantime, please use the workaround posted.

srinivas balivada

unread,
Jul 26, 2016, 4:31:17 PM7/26/16
to Google App Engine
Hello Sir,

Can you please help  me how to solve this issue ,

"No module named webapp2"

Regards and Thanks,
Srinivas B

Iaroslav Karandashev

unread,
Sep 27, 2016, 9:11:02 AM9/27/16
to Google App Engine
Is there any updates on this topic?
I have faced the same issue

 from google.appengine.ext import webapp
  File "google3/tools/autopar/zipimport_modern.py", line 536, in load_module
  File "google3/tools/autopar/zipimport_modern.py", line 842, in LoadPythonModule
  File "google3/apphosting/tools/devappserver2/google_appengine/google/appengine/ext/webapp/__init__.py", line 199, in <module>
    from webapp2 import *
ImportError: No module named webapp2
INFO:root:default: "GET / HTTP/1.1" 500 -

Iaroslav Karandashev

unread,
Sep 27, 2016, 6:21:36 PM9/27/16
to Google App Engine
I have solved this issue by changing BUILD file.
Reply all
Reply to author
Forward
0 new messages