所以我刚刚将 django 更新到 1.2.3,现在当我尝试运行“python manage.py shell”以在 django 环境中工作时,出现以下错误。

Traceback (most recent call last):


File "manage.py", line 11, in <module>
    execute_manager(settings)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/opt/local/lib/python2.5/site-packages/django/core/management/commands/shell.py", line 18, in handle_noargs
    loaded_models = get_models()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 167, in get_models
    self._populate()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 64, in _populate
    self.load_app(app_name)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/loading.py", line 78, in load_app
    models = import_module('.models', app_name)
  File "/opt/local/lib/python2.5/site-packages/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/opt/local/lib/python2.5/site-packages/django_celery-2.0.3-py2.5.egg/djcelery/models.py", line 7, in <module>
    from celery import conf
  File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/conf.py", line 6, in <module>
    from celery import routes
  File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/routes.py", line 2, in <module>
    from celery.utils import instantiate, firstmethod, mpromise
  File "/opt/local/lib/python2.5/site-packages/celery-2.0.3-py2.5.egg/celery/utils/__init__.py", line 9, in <module>
    import importlib
ImportError: No module named importlib

有任何想法吗。我似乎无法找到这里发生了什么,尽管我可以告诉我我在我的网络服务器上运行相同的版本,但我没有出现相同的错误。

最佳答案

我相信这是在 Python 2.7/3.1 中添加的 importlib。您可以在此处下载 pyton 2.5 的端口:

  • importlib 1.0.1 - Backport of importlib.import_module() from Python 2.7

  • 还要检查 setup.cfg 底部附近的 celery ,并确保满足所有其他要求(朝向脚本底部)。

    关于python - Django/Celery 找不到 importlib,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3897436/

    10-12 16:41