2

When I run the following hellow world program (with the GAE Launcher) it works:

import webapp2

class MainPage(webapp2.RequestHandler):
    def get(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.out.write('Hello, webapp World!')

app = webapp2.WSGIApplication([('/', MainPage)],
    debug=True)

However If i go to the terminal I can't import webapp2:

C:\Users\Robert>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import webapp2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named webapp2
>>>

Also my IDE provides no autocomplete for webapp2 objects.

Seeing as GAE Launcher uses the same python version as I use in the terminal, I'm confused as to how the import must work within the GAE launcher.

Chris Martin
  • 30,334
  • 10
  • 78
  • 137
Rusty Rob
  • 16,489
  • 8
  • 100
  • 116

3 Answers3

5

It's not a bug. Appengine SDK includes webapp2 since version 1.6.

By default, you can not import webapp2 from the terminal because google_appengine is not added to PATH by default.

Add the following dirs to Python's PATH; C:\Program Files\Google\google_appengine\ and C:\Program Files\Google\google_appengine\lib\ and you will have the same enviroment the SDK provides.

Christopher Ramírez
  • 1,710
  • 10
  • 13
  • 1
    Awesome, I assume this means I need a python path variable. I'll create one as per http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7 – Rusty Rob Mar 02 '12 at 00:08
2

i dont use the GAE launcher but im pretty sure that if you start your app with the launcher it puts some packages into your pythonpath thats why you can import it in your app.
i bet you cant import something from the gooogle.appengine.ext or other gae libs from your python prompt but you can in your app.

aschmid00
  • 7,038
  • 2
  • 47
  • 66
  • Cool thanks. I just noticed this folder C:\Program Files\Google\google_appengine\lib\webapp2 which contains setup.py which probably would install it if I need it – Rusty Rob Mar 01 '12 at 01:26
0

Are you using the python27 runtime? If so, webapp2 is available on both the development server, regardless of whether you have it installed, and the production runtime. If you're able to import webapp2 under the old python 2.5 runtime, I would consider this a bug.

Anand Mistry
  • 512
  • 2
  • 4