Django nose giving "ImportError: cannot import name setup"?
Django nose giving "ImportError: cannot import name setup"?
当我 运行 默认服务器时,安装在 virtualenv 中的 Django-nose 在 runner.py 中给出 "ImportError: cannot import name setup"。在进行追溯时,我得到了这个:
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
Django 1.5 已经有很长一段时间没有得到支持了,django-nose 在其最新版本中已经降低了兼容性。 django.setup()
是在 Django 1.7 中添加的。
您需要升级 Django 或将 django-nose 降级到兼容版本。我建议将 Django 升级到 supported version,这样您就会收到错误修正和安全更新。
Django-nose 在 version 1.4.4 中放弃了对 Django 1.5 的支持。
我能够通过在 1.4.3 安装 django-nose 来解决这个问题。
pip install django-nose==1.4.3
当我 运行 默认服务器时,安装在 virtualenv 中的 Django-nose 在 runner.py 中给出 "ImportError: cannot import name setup"。在进行追溯时,我得到了这个:
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
Django 1.5 已经有很长一段时间没有得到支持了,django-nose 在其最新版本中已经降低了兼容性。 django.setup()
是在 Django 1.7 中添加的。
您需要升级 Django 或将 django-nose 降级到兼容版本。我建议将 Django 升级到 supported version,这样您就会收到错误修正和安全更新。
Django-nose 在 version 1.4.4 中放弃了对 Django 1.5 的支持。
我能够通过在 1.4.3 安装 django-nose 来解决这个问题。
pip install django-nose==1.4.3