gpt4 book ai didi

google-app-engine - Google App Engine Python 2.7 教程无法运行

转载 作者:太空宇宙 更新时间:2023-11-03 15:19:29 24 4
gpt4 key购买 nike

我正在学习 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我正在使用应用引擎启动器。有什么想法吗?

最佳答案

我也遇到了同样的问题。当您直接从站点复制时,它与文件编码有关。避免这样做并确保您的文件具有正确的 yaml 编码。这是一个让您开始使用 app.yaml 文件的示例

application: your-app-id
version: 1
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
script: helloworld.application

关于google-app-engine - Google App Engine Python 2.7 教程无法运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17515144/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com