我的GF正在嘗試遵循Udacity's Web Development course,但她遇到了問題。我無法解決它。剛開始的時候,我們必須創建一個運行在AppEngine上的「hello world」Python腳本。使用簡單的Python導入導致語法錯誤
所以,文件:
的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)
但是,當我運行的應用程式(槽的GUI啓動或dev_appserver.py)並在瀏覽器中打開應用程序我得到這個錯誤(在控制檯中):
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
我們在OSX 10.8.4上,當我在終端中運行python時,它告訴我我已經安裝了2.7.2版本。 AppEngine啓動器(或SDK)版本是1.8.2。
有人嗎?我已經嘗試過很多事情,但現在沒有成功,我真的不知道該怎麼做了(我不是Python開發者),我真的想讓這個事情工作,所以我的GF可以繼續學習:)
該文件可能是與Windows行結尾一起保存的? –
因爲她在Mac上做了Sublime的所有工作,所以我不應該這麼想。但我會檢查一下,以確保。 –
這是一個長鏡頭;但是''import''的'i'之前的字符*在這裏拋棄了Python。 –