【问题标题】:Google app engine dev_appserver.py problems谷歌应用引擎 dev_appserver.py 问题
【发布时间】:2013-09-04 10:47:44
【问题描述】:

我刚开始使用谷歌应用引擎,我遵循了谷歌应用引擎上的基本 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)

【问题讨论】:

  • 错误提示没有文件或目录。 helloworld 目录是否存在于您运行命令的目录中,并且其中是否包含 app.yaml?
  • 确实,我用其中的两个文件更新了我的帖子。我确保在运行 dev_appserver.py 之前 cd 进入该目录,但仍然不行。
  • 如果你 cd 进入helloworld 目录,那么命令应该是dev_appserver.py . 参数是包含 app.yaml 的目录的路径。如果您在该目录中,则路径是当前目录的完整路径或.

标签: python google-app-engine


【解决方案1】:

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

gcloud components install app-engine-go

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

【讨论】:

    【解决方案2】:

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

    python dev_appserver.py helloworld/

    也许这会有所帮助。

    【讨论】:

      【解决方案3】:
      1. 当您首次启动 Google App Engine 时,系统会提示您是否要创建“命令符号链接”——请务必单击“确定”,然后输入管理员密码。这使您可以在 /usr/local/bin 文件夹中为命令 dev_appserver.py 使用符号链接。

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

        $: /usr/local/bin/dev_appserver.py helloworld
        

      这是example 我的浏览器、终端和查找器窗口的样子。

      作为参考,here 是 O'Reilly 在 Mac 上安装/运行谷歌应用引擎的指南。

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

      【讨论】:

        【解决方案4】:

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

        而不是:

        dev_appserver.py YOUR_DIRECTORY
        

        试试:

        py dev_appserver.py YOUR_DIRECTORY
        

        或者:

        python dev_appserver.py YOUR_DIRECTORY
        

        【讨论】:

          【解决方案5】:

          创建目录test-dir

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

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

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

          在终端:

          进入测试目录

          运行:google-cloud-sdk/bin/dev_appserver.py helloworld/

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 2015-01-12
            • 1970-01-01
            • 1970-01-01
            • 2011-05-13
            • 1970-01-01
            • 2023-03-13
            • 2019-07-30
            相关资源
            最近更新 更多