pythondjangodjango-nose

Django nose giving "ImportError: cannot import name setup"?


Django-nose installed in virtualenv is giving "ImportError: cannot import name setup" in runner.py when I run default server. On doing traceback I get this:

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
`

I found this about django.setup() on django documentation, though most of problems like this have pythonic issues rather than with Django


Solution

  • Django 1.5 hasn't been supported for quite a while now, and django-nose has dropped compatibility in their more recent versions. django.setup() was added in Django 1.7.

    You need to upgrade Django or downgrade django-nose to a compatible version. I would recommend to upgrade Django to a supported version so you'll receive bugfixes and security updates.