无法在gae(python 2.7)中运行简单的helloworld

无法在gae(python 2.7)中运行简单的helloworld,python,google-app-engine,Python,Google App Engine,我正在尝试在GoogleAppengine1.6.4中为Python2.7运行该程序 不能运行一个简单的helloworld是非常令人沮丧的。我会很感激这里的任何帮助 我遇到的错误:- shadyabhi@MBP-archlinux ~/codes/gae $ dev_appserver.py helloworld/ INFO 2012-04-06 23:25:55,030 appengine_rpc.py:160] Server: appengine.google.com INFO

我正在尝试在GoogleAppengine1.6.4中为Python2.7运行该程序

不能运行一个简单的helloworld是非常令人沮丧的。我会很感激这里的任何帮助

我遇到的错误:-

shadyabhi@MBP-archlinux ~/codes/gae $ dev_appserver.py helloworld/
INFO     2012-04-06 23:25:55,030 appengine_rpc.py:160] Server: appengine.google.com
INFO     2012-04-06 23:25:55,034 appcfg.py:582] Checking for updates to the SDK.
INFO     2012-04-06 23:25:56,709 appcfg.py:616] This SDK release is newer than the advertised release.
WARNING  2012-04-06 23:25:56,710 datastore_file_stub.py:513] Could not read datastore data from /tmp/dev_appserver.datastore
INFO     2012-04-06 23:25:56,773 dev_appserver_multiprocess.py:647] Running application dev~helloworld on port 8080: http://localhost:8080
INFO     2012-04-06 23:25:56,774 dev_appserver_multiprocess.py:649] Admin console is available at: http://localhost:8080/_ah/admin
WARNING  2012-04-06 23:26:00,928 py_zipimport.py:139] Can't open zipfile /usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info: IOError: [Errno 13] file not accessible: '/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info'
ERROR    2012-04-06 23:26:01,101 wsgi.py:189] 
Traceback (most recent call last):
  File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app
INFO     2012-04-06 23:26:01,110 dev_appserver.py:2884] "GET / HTTP/1.1" 500 -
ERROR    2012-04-06 23:26:01,479 wsgi.py:189] 
Traceback (most recent call last):
  File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 187, in Handle
    handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
  File "/opt/google-appengine-python/google/appengine/runtime/wsgi.py", line 239, in _LoadHandler
    raise ImportError('%s has no attribute %s' % (handler, name))
ImportError: <module 'helloworld' from '/home/shadyabhi/codes/gae/helloworld/helloworld.pyc'> has no attribute app
INFO     2012-04-06 23:26:01,486 dev_appserver.py:2884] "GET /favicon.ico HTTP/1.1" 500 -
shadyabhi@MBP-archlinux~/code/gae$dev_appserver.py helloworld/
信息2012-04-06 23:25:55030 appengine_rpc.py:160]服务器:appengine.google.com
信息2012-04-06 23:25:55034 appcfg.py:582]正在检查SDK的更新。
信息2012-04-06 23:25:56709 appcfg.py:616]此SDK版本比公布的版本更新。
警告2012-04-06 23:25:56710数据存储\u文件\u存根.py:513]无法从/tmp/dev\u appserver.datastore读取数据存储数据
INFO 2012-04-06 23:25:56773 dev_appserver_multiprocess.py:647]在端口8080上运行应用程序dev~helloworld:http://localhost:8080
信息2012-04-06 23:25:56774 dev_appserver_multiprocess.py:649]管理控制台位于:http://localhost:8080/_ah/admin
警告2012-04-06 23:26:00928 py_zipimport.py:139]无法打开zipfile/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info:IOError:[Errno 13]文件不可访问:'/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info'
错误2012-04-06 23:26:01101 wsgi.py:189]
回溯(最近一次呼叫最后一次):
文件“/opt/google-appengine-python/google/appengine/runtime/wsgi.py”,第187行,在句柄中
handler=\u config\u handle.add\u wsgi\u中间件(self.\u LoadHandler())
文件“/opt/google-appengine-python/google/appengine/runtime/wsgi.py”,第239行,在LoadHandler中
raise ImportError(“%s”没有属性“%s%”(处理程序,名称))
ImportError:没有属性app
INFO 2012-04-06 23:26:01110 dev_appserver.py:2884]“GET/HTTP/1.1”500-
错误2012-04-06 23:26:01479 wsgi.py:189]
回溯(最近一次呼叫最后一次):
文件“/opt/google-appengine-python/google/appengine/runtime/wsgi.py”,第187行,在句柄中
handler=\u config\u handle.add\u wsgi\u中间件(self.\u LoadHandler())
文件“/opt/google-appengine-python/google/appengine/runtime/wsgi.py”,第239行,在LoadHandler中
raise ImportError(“%s”没有属性“%s%”(处理程序,名称))
ImportError:没有属性app
INFO 2012-04-06 23:26:01486 dev_appserver.py:2884]“GET/favicon.ico HTTP/1.1”500-

github上的文件和的文件之间的一个区别是helloworld文件似乎没有命名为helloworld.py。这可能会有帮助吗

此外,您是否需要helloworld顶部的PROJECT_DIR变量


如果您正在努力让基础教程正常工作,那么您应该做的第一件事就是确保您的项目与google示例完全相同。

通过检查您的git repo,我发现helloworld不是一个.py文件。

将其重命名为helloworld.py,您就可以开始了。

如果您使用的是python2.7库,则教程中会出现错误

这行不正确:

application = webapp2.WSGIApplication([('/', MainPage)], debug=True)
正确的行应该是:

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

WSGI处理程序正在抱怨,因为它正在寻找一个名为“app”的属性。

这段代码帮了我的忙(注意“application”替换为“app”):


在我直接从谷歌的网站上复制代码后,我得到了500个错误。上述措施都不起作用

我所要做的就是更改每行代码的缩进(即将空格更改为制表符)和宾果游戏


这对我很有用。

使用运行时python 2.7时,不必使用main函数

去掉这个

if __name__ == '__main__':
      run_wsgi_app(app)
只要打个电话

app = webapp.WSGIApplication(
[('/', MainHandler),
('/upload', UploadHandler), 
('/serve/([^/]+)?', ServeHandler),], debug=True)

我一直在用python 2.7编写教程,在配置文件app.yaml中发现了同样的错误 最后一行是

脚本:helloworld.application

应该是


脚本:helloworld.app

我可以对警告做些什么吗?
警告2012-04-07 19:18:24054 py_zipimport.py:139]无法打开zipfile/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info:IOError:[Errno 13]文件不可访问:'/usr/lib/python2.7/site-packages/setuptools-0.6c11.egg-info'
?警告是无害的。但是,google不允许您从站点软件包目录导入,因此您可能可以通过pythonpath修复此问题。memcache与此无关,也没有任何理由认为它与此有关。@NickJohnson谢谢,我已将memcache的内容删去。这似乎是一个非常常见的解决方案,看起来像是一个类似于OP的问题。我在GAE方面没有任何经验,只是因为我在原始问题中看到的问题才得到回答。令人惊讶的是,这个答案对我同样有效!我把我的应用程序命名为
application
,编译器一直在抱怨它!我把它改成了app和wallah。。。我回来了!谢谢我从谷歌登陆这里,发现正好相反的情况是我的问题。也就是说,我有
app=…
,但它必须是
application=…
。py和.yaml文件之间不匹配。你可以解决任何一个问题。在yaml中,编辑行“script:webapp.application”
app = webapp.WSGIApplication(
[('/', MainHandler),
('/upload', UploadHandler), 
('/serve/([^/]+)?', ServeHandler),], debug=True)