谷歌应用引擎dev_appserver.py问题

时间:2013-09-01 01:25:11

标签: python google-app-engine

我刚开始使用谷歌应用引擎,我在谷歌应用引擎上关注了基本的hello world示例。

https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworld

在helloworld文件夹中创建了两个文件。

我不想使用GUI,我更喜欢使用mac终端来使用这个应用程序。我想在本地主机localhost:80上通过终端启动此应用程序。

在本地运行我的基本helloworld应用程序我所说的是

$ dev_appserver.py helloworld。但我得到了这个错误。

Traceback (most recent call last):
  File "/usr/local/bin/dev_appserver.py", line 184, in <module>
    _run_file(__file__, globals())
  File "/usr/local/bin/dev_appserver.py", line 180, 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 727, in <module>
    main()
  File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 720, 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 554, 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__
    module_configuration = ModuleConfiguration(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 271, in _parse_configuration
    with open(configuration_path) as f:
IOError: [Errno 2] No such file or directory: 'helloworld'

我在helloworld目录中有两个文件。 app.yaml中

application: your-app-id
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('Hello, World!')


application = webapp2.WSGIApplication([
    ('/', MainPage),
], debug=True)

5 个答案:

答案 0 :(得分:3)

我遇到了同样的问题。经过一番努力后,google_appengine目录内而不是helloword目录中的命令对我起作用了:

python dev_appserver.py helloworld/

也许这有帮助。

答案 1 :(得分:3)

安装google cloud sdk之后,你运行了吗

for(int y=0;x<=scoundArray.length;y++)

文档在组织方面有点荒谬。我刚开始时完全错过了这个

答案 2 :(得分:0)

  1. 首次启动Google App Engine时,会出现提示,询问您是否要制作&#34; Command Symlinks&#34; - 确保单击“确定”,然后输入管理员密码。这使您可以在/ usr / local / bin文件夹中使用命令dev_appserver.py的符号链接。

  2. 在终端(命令行)中输入以下内容

    $: /usr/local/bin/dev_appserver.py helloworld
    
  3. 这是example我的浏览器,终端和取景器窗口的样子。

    作为参考,here是在Mac上安装/运行Google应用引擎的O&#39; Reilly指南。

    1. 要关闭Web服务器,请确保终端窗口处于活动状态,然后按Control-C

答案 3 :(得分:0)

从目录... \ Google \ Cloud SDK \ google-cloud-sdk \ bin:

而不是:

dev_appserver.py YOUR_DIRECTORY

尝试:

py dev_appserver.py YOUR_DIRECTORY

或者:

python dev_appserver.py YOUR_DIRECTORY

答案 4 :(得分:0)

创建目录test-dir

在此目录中提取google-cloud-sdk

在test-dir目录中创建另一个目录'helloworld'

https://webapp2.readthedocs.io/en/latest/tutorials/gettingstarted/helloworld.html#tutorials-gettingstarted-helloworld创建两个文件后 在helloworld目录中

在终端中:

转到test-dir目录

运行:[2,3]