While I'm able to get my "Hello, World" program running on Google App Engine (GAE), it only works when I create a version that doesn't rely on the webapp2 import. Why isn't the import working? What I need to do to fix it?
Version of helloworld.py that works:
print 'Content-Type: text/plain'
print ''
print 'Hello, World!!'
Version of helloworld.py that does not work:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, World!')
app = webapp2.WSGIApplication([('/', MainPage)], debug=True)
This second version renders as a blank page.
I think the problem is that the webapp2 import isn't working. When I run python from within the same directory as my hello world program from the command line I get the following:
Brians-MacBook-Air-2:app_engine_hello_world brian$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
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
However, I see webapp2.py in the following directory:
Brians-MacBook-Air-2:webapp2 brian$ pwd
/Users/brian/Repos/app_engine_hello_world/build/webapp2
Also, I'm running python 2.7 installed in the following location:
Brians-MacBook-Air-2:app_engine_hello_world brian$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
EDIT: Adding my app.yaml file & some other potentially useful info...
application: hello-world-cs253
version: 1
runtime: python27
api_version: 1
threadsafe: no
handlers:
- url: /.*
script: helloworld.py
I'm using version 1.7.0 - 2012-06-26 of the SDK / GAE Launcher
Results are the same in Chrome, Firefox, and Safari
app.yaml? What browser are you using? Are you using the SDK? Which version? If/Users/brian/Repos/app_engine_hello_world/buildis not in yourPYTHON_PATH, then it won't import. To check itecho $PYTHON_PATHor within the Python REPLimport sysandprint sys.path. - bossylobsterapp.yaml, browser, and SDK info. Using IDLE, I confirmed that/Users/brian/Repos/app_engine_hello_world/buildis NOT in my PYTHON_PATH. Can you tell me how to add directories to PYTHON_PATH? Is it the same as adding to $PATH? Sorry if this a rookie question. - Brian Goler