在virtualenv中安装的Django-nose正在提供" ImportError:无法导入名称设置"在我运行默认服务器时的runner.py中。在做追溯时,我得到了这个:
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/core/management/base.py", line 250, in execute
translation.activate('en-us')
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 90, in activate
return _trans.activate(language)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 183, in activate
_active.value = translation(language)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 172, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 154, in _fetch
app = import_module(appname)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django_nose/__init__.py", line 5, in <module>
from django_nose.runner import BasicNoseRunner, NoseTestSuiteRunner
File "/home/sid/.virtualenvs/workbench/local/lib/python2.7/site-packages/django_nose/runner.py", line 19, in <module>
from django import setup
ImportError: cannot import name setup
`
我在django文档中找到了关于django.setup()的内容,尽管像这样的大多数问题都有pythonic问题而不是Django
答案 0 :(得分:5)
Django 1.5现在已经有很长一段时间没有得到支持了,而django-nose已经在最新版本中降低了兼容性。 Django 1.7中添加了django.setup()
。
您需要升级Django或将django-nose降级为兼容版本。我建议将Django升级到supported version,这样您就会收到错误修正和安全更新。
答案 1 :(得分:0)
Django-nose在version 1.4.4中放弃了对Django 1.5的支持。
我能够通过在1.4.3上安装django-nose来解决此问题。
pip install django-nose==1.4.3