我正在关注https://developers.google.com/appengine/docs/python/gettingstartedpython27/introduction
上的教程我的app.yaml是:
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /
script: helloworld.application
和helloworld.py是:
import webapp2
class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.write('Hi')
application = webapp2.WSGIApplication([
('/', MainPage),
], debug=True)
日志输出为:
*** Running dev_appserver with the following flags:
--skip_sdk_update_check=yes --port=10090 --admin_port=8001
Python command: /usr/bin/python2.7
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 182, in <module>
_run_file(__file__, globals())
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/dev_appserver.py", line 178, in _run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 695, in <module>
main()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 688, in main
dev_server.start(options)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 525, in start
options.yaml_files)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
server_configuration = ServerConfiguration(yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
self._yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 272, in _parse_configuration
return appinfo_includes.ParseAndReturnIncludePaths(f)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo_includes.py", line 63, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo.py", line 1715, in LoadSingleAppInfo
listener.Parse(app_info)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError
我在macbook pro上运行,使用python 2.7 我正在使用应用引擎启动器。有什么想法吗?
答案 0 :(得分:10)
我也经历过同样的问题。当您直接从站点复制时,它与文件编码有关。避免这样做并确保您的文件具有正确的yaml编码。这是一个让你开始使用app.yaml文件的例子
application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /.*
script: helloworld.application
答案 1 :(得分:8)
在我的情况下,问题是“脚本”行的缩进级别。
就像:
handlers:
- url: /.*
script: helloworld.php
但应该是这样的:
handlers:
- url: /.*
script: helloworld.php
答案 2 :(得分:4)
我将来自Chrome的app.yaml剪切并粘贴到gnome-terminal,并得到了同样的错误。最后我在vi中打开了app.yaml,发现它包含一个UTF文本方向标记。一旦我删除它,一切都开始工作。
故事的道德:如果您看到此错误,请检查您的app.yaml是否有错误的标记,错误的字符以及其他任何不良内容。 (虽然不是DOS换行符 - 开发应用程序服务器应对这些。)
答案 3 :(得分:1)
尝试删除app.yaml中应用程序行之前的特殊字符。它似乎不在那里,只是将光标导航到然后按退格键将其删除之前的位置。
答案 4 :(得分:0)
要完成@Fernando Basso的回答,脚本行上的正确意图应该是两个空格,而不是一个标签,因为它将被读作一个也会产生错误的\ t字符。