我上传了Google App Engine应用程序,该应用程序位于url developers.google.com/appengine/docs/python/memcache/usingmemcache#Memcache
当我在Google App Engine Launcher上运行该应用程序时,它会运行,但网站会显示: (第一个错误是我们没有Python“PIL”模块,但我没有使用图像。你能否建议导致错误的原因?
*** Running dev_appserver with the following flags:
--skip_sdk_update_check=yes --port=13080 --admin_port=8005
Python command: /usr/bin/python2.7
INFO 2014-01-17 20:43:22,217 devappserver2.py:660] Skipping SDK update check.
WARNING 2014-01-17 20:43:22,222 api_server.py:331] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-01-17 20:43:22,226 api_server.py:138] Starting API server at: localhost:55385
INFO 2014-01-17 20:43:22,230 dispatcher.py:171] Starting module "default" running at: localhost:13080
INFO 2014-01-17 20:43:22,238 admin_server.py:117] Starting admin server at: localhost:8005
ERROR 2014-01-17 20:43:24,601 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw2' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,607 module.py:617] default: "GET / HTTP/1.1" 500 -
ERROR 2014-01-17 20:43:24,727 wsgi.py:262]
Traceback (most recent call last):
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/Users/Desktop/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/runtime/wsgi.py", line 301, in _LoadHandler
raise err
ImportError: <module 'guestbookw12' from '/Users/guestbookw2/guestbookw2.pyc'> has no attribute application
INFO 2014-01-17 20:43:24,732 module.py:617] default: "GET /favicon.ico HTTP/1.1" 500 -
答案 0 :(得分:0)
确保您在上传应用程序的路径中包含以下文件:
index.yaml (自动生成;此时您无需在此处添加或更改任何内容)。
favicon.ico (格式正确;如果我没记错的话,应为16x16或32x32像素。)
main.py (映射您网站中的所有路径;示例如下):
from webapp2 import WSGIApplication
from Server import MainRequestHandler
from Server import SomeRequestHandler
from Server import OtherRequestHandler
app = WSGIApplication([
('/' ,MainRequestHandler),
('/abc' ,SomeRequestHandler),
('/def' ,SomeRequestHandler),
('/xyz' ,OtherRequestHandler),
])
app.yaml (包含以下内容;使用<...>
,您需要设置值):
application: <the app-id you chose when use signed in for GAE>
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: main.app
libraries:
- name: webapp2
version: "2.5.1" // you might need to change this as well
注意强>:
如果您希望避免处理'favicon.ico'请求,则必须删除文件'app.yaml'中的引用。
<强>补充强>:
您需要实现在'main.py'中导入的所有请求处理程序。
在上面的示例中,'main.py'希望在名为'Server'的Python模块中找到它们。
每个请求处理程序都必须继承从class RequestHandler
导入的webapp2
。
补充#2 :
为了解决'PIL'问题(如果内存正常运行会出现类似问题),只需安装即可。
从Windows命令行输入:pip install pil。