3

我正在尝试基本的 helloworld 示例(https://developers.google.com/appengine/docs/python/gettingstartedpython27/helloworldHTTP Error 301: Moved Permanently ),并且每当我尝试使用 dev_appserver.py 测试我的代码时都会收到错误消息

我拥有的 2 个文件完全是从 developer.google.com 网站复制和粘贴的。我已经包含了 dev_appserver.py 在 PATH 和 PYTHONPATH 中的位置

我在 Linux 上使用 python 2.7.3 和 appengine v1.8.4 运行它

当我运行它时,终端上的输出是......

[verma@localhost python]$ dev_appserver.py helloworld/
WARNING  2013-09-11 04:45:49,988 api_server.py:327] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO     2013-09-11 04:45:49,999 api_server.py:138] Starting API server at: http://localhost:57128
INFO     2013-09-11 04:45:50,021 dispatcher.py:164] Starting module "default" running at: http://localhost:8080
INFO     2013-09-11 04:45:50,023 admin_server.py:117] Starting admin server at: http://localhost:8000
HTTPError()
HTTPError()
Traceback (most recent call last):
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 256, in __call__
    return app(environ, start_response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 97, in __call__
    self._flush_logs(response.get('logs', []))
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 233, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
    rpc.CheckSuccess()
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "/usr/lib64/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib64/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 301: Moved Permanently
Traceback (most recent call last):
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "/home/verma/Documents/gae/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 256, in __call__
    return app(environ, start_response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 97, in __call__
    self._flush_logs(response.get('logs', []))
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 233, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
    rpc.CheckSuccess()
  File "/home/verma/Documents/gae/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "/home/verma/Documents/gae/google_appengine/google/appengine/tools/appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "/usr/lib64/python2.7/urllib2.py", line 410, in open
    response = meth(req, response)
  File "/usr/lib64/python2.7/urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib64/python2.7/urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "/usr/lib64/python2.7/urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 301: Moved Permanently
INFO     2013-09-11 04:46:01,635 module.py:593] default: "GET / HTTP/1.1" 500 -

我有一种感觉,我错过了一些非常基本的东西,但找不到。顺便说一句,这是几天前的工作,我不记得做过任何愚蠢的事情来打破这个:-(

4

2 回答 2

4

快速解决您的问题。

打开文件 [GAE 安装路径]/google/appengine/tools/appengine_rpc.py"

转到578号线

注释掉以下行

# opener.add_handler(fancy_urllib.FancyProxyHandler())

于 2014-11-24T11:03:20.753 回答
1

似乎 dev_apserver 需要每隔一段时间联系互联网上的谷歌应用引擎服务器(即使你不要求它检查更新)。我遇到的问题是它在代理后面时无法访问谷歌服务器(即使我已经正确导出了 http_proxy 和 https_proxy)。

当我使用直接连接到互联网的有线网络时,我完全没有问题。

一旦 dev_appserver 'call home',它将在代理后面继续工作几天而不会出现问题,然后我又遇到了这个问题。

过去,我在连接 wifi 时也注意到了类似的行为。

似乎 dev_appserver 在没有代理的有线网络上工作得最好。

这仅基于我的观察;如果有人可以对这个问题给出明确的答案,那就太好了。

于 2013-09-24T03:48:23.387 回答