无法在dev_server上运行appengine-admin

时间:2009-04-26 00:26:49

标签: python google-app-engine

我决定尝试这个项目:

http://code.google.com/p/appengine-admin/wiki/QuickStart

为了实验,我带了app-engine附带的演示留言簿。进口公园看起来像这样:

import cgi
import datetime
import wsgiref.handlers

from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google import appengine_admin

db模型和admin看起来像这样

class Greeting(db.Model):

 author = db.UserProperty()
 content = db.StringProperty(multiline=True)
 date = db.DateTimeProperty(auto_now_add=True)

class AdminGreeting(appengine_admin.ModelAdmin):

 model = Greeting
 listFields = ('author','content','date')
 editFields = ('author','content','date')

appengine_admin.register(AdminGreeting)

然而,我得到了这个例外,试图运行该网站:

File "/home/<username>/python/google_appengine/google/appengine/tools/    dev_appserver.py", line 2875, in _HandleRequest
    base_env_dict=env_dict)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 387, in Dispatch
    base_env_dict=base_env_dict)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 2162, in Dispatch
    self._module_dict)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 2080, in ExecuteCGI
    reset_modules = exec_script(handler_path, cgi_path, hook)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1976, in ExecuteOrImportScript
    exec module_code in script_module.__dict__
  File "/home/<username>/python/google_appengine/demos/guestbook/guestbook.py", line 37, in <module>
    appengine_admin.register(AdminGreeting)
  File "/home/<username>/python/google_appengine/google/appengine_admin/model_register.py", line 120, in register
    modelAdminInstance = modelAdminClass()
  File "/home/<username>/python/google_appengine/google/appengine_admin/model_register.py", line 64, in __init__
    self._extractProperties(self.listFields, self._listProperties)
  File "/home/<username>/python/google_appengine/google/appengine_admin/model_register.py", line 76, in _extractProperties
    storage.append(PropertyWrapper(getattr(self.model, propertyName), propertyName))
  File "/home/<username>/python/google_appengine/google/appengine_admin/model_register.py", line 17, in __init__
    logging.info("Caching info about property '%s'" % name)
  File "/usr/lib/python2.6/logging/__init__.py", line 1451, in info
    root.info(*((msg,)+args), **kwargs)
  File "/usr/lib/python2.6/logging/__init__.py", line 1030, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib/python2.6/logging/__init__.py", line 1142, in _log
record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
  File "/usr/lib/python2.6/logging/__init__.py", line 1117, in makeRecord
rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
  File "/usr/lib/python2.6/logging/__init__.py", line 272, in __init__
from multiprocessing import current_process
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1089, in decorate
return func(self, *args, **kwargs)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1736, in load_module
return self.FindAndLoadModule(submodule, fullname, search_path)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1089, in decorate
    return func(self, *args, **kwargs)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1638, in FindAndLoadModule
description)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1089, in decorate
return func(self, *args, **kwargs)
  File "/home/<username>/python/google_appengine/google/appengine/tools/dev_appserver.py", line 1589, in LoadModuleRestricted
description)
  File "/usr/lib/python2.6/multiprocessing/__init__.py", line 83, in <module>
    import _multiprocessing
ImportError: No module named _multiprocessing
INFO     2009-04-25 23:34:27,628 dev_appserver.py:2934] "GET / HTTP/1.1" 500 -

知道什么可能出错?

8 个答案:

答案 0 :(得分:4)

您似乎正在使用Python 2.6(假设某些消息来自/usr/lib/python2.6 ......中的文件),但Google App Engine需要Python 2.5(任何2.5.x都可以使用任何版本的x),因此您应该安装并使用它来运行App Engine SDK。

答案 1 :(得分:3)

Google App Engine仅支持Python 2.5,而您使用的是较新的版本。

从您的目录看,您可能在Linux上(或者它是Mac?)。比方说,Ubuntu你可以“sudo apt-get install python2.5”(它根本不会影响你的Python 2.6),然后而不是:

<path-to-gae>/dev_appserver.py ...

DO

python2.5 <path-to-gae>/dev_appserver.py ...

这比仅仅轻松开发2.6并在2.5上部署更好,这肯定会在以后遇到麻烦。

答案 2 :(得分:3)

正如其他人所说,这个问题发生在Python 2.6中。我使用了this comment in the App Engine issue tracker中提出的修补程序:

A quickfix is to create a file in your app's root named `_multiprocessing.py' with 
the contents:

  import multiprocessing

This way it's possible to import the _multiprocessing module.

It worked for me using Python 2.6.2

Cheers,
Kaji

答案 3 :(得分:2)

为了在我的本地机器(使用2.6)和GAE上工作,我使用了:

import sys, logging
if sys.version[:3] == "2.6": logging.logMultiprocessing = 0

答案 4 :(得分:1)

只需在你的something.py

的顶部执行以下操作

导入日志记录 logging.logMultiprocessing = 0

答案 5 :(得分:1)

import logging
logging.logMultiprocessing = 0

为我工作

答案 6 :(得分:0)

我一直在使用GAE和python2.6(可能是2.6.1),并且每件事都运行良好。

但现在我得到了相同的_multiprocess导入错误。(python2.6.2)。

答案 7 :(得分:0)

import logging
logging.logMultiprocessing = 0

也为我工作。在上传到GAE之前,请注释这些行。