My GF is trying to follow the Udacity's Web Development course but she ran into a problem. And I can't solve it. It's just at the start when one has to create a "hello world" Python script that runs on AppEngine.
So, the files:
app.yaml:
application: focus-invention-298
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.app
helloworld.py:
# -*- coding: utf8 -*-
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hello, Udacity!')
application = webapp2.WSGIApplication([('/', MainPage)], debug=True)
But, when I run the app (either trough the GUI launcher or with the dev_appserver.py) and open the app in the browser I get this error (in the console):
Traceback (most recent call last):
File "/Users/Kaja/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Kaja/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
handler = __import__(path[0])
File "/Users/Kaja/Documents/udacity/helloworld.py", line 3
import webapp2
^
SyntaxError: invalid syntax
INFO 2013-08-05 14:06:00,875 module.py:595] default: "GET / HTTP/1.1" 500 -
ERROR 2013-08-05 14:06:01,012 wsgi.py:219]
Traceback (most recent call last):
File "/Users/Kaja/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 196, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Kaja/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 255, in _LoadHandler
handler = __import__(path[0])
File "/Users/Kaja/Documents/udacity/helloworld.py", line 3
import webapp2
^
SyntaxError: invalid syntax
We are on OSX 10.8.4 and when I run python in the terminal it tells me I have 2.7.2 version installed. AppEngine launcher (or SDK) version is 1.8.2.
Anyone? I've tried so many things now without success that I really don't know what to do anymore (I'm not a python dev) and I really wanna make this thing work so my GF can continue learning :)
There are bytes before the import
statement (unicode non-breaking whitespace characters are a prime candidate) that could cause this.
Check the first 50 bytes or so:
print repr(open('helloworld.py', 'rb').read(50))
If you see a sequence like '\xc2\xa0'
then you have UTF-8 encoded non-breakable space characters in there, for example.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments