python - Django Nose 给出 "ImportError: cannot import name setup"?

标签 python django django-nose

当我运行默认服务器时,安装在 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.setup() 的内容在 django 文档上,尽管像这样的大多数问题都有 pythonic 问题而不是 Django

最佳答案

Django 1.5 已经有很长一段时间没有得到支持了,django-nose 在其最新版本中已经降低了兼容性。 django.setup() 是在 Django 1.7 中添加的。

您需要升级 Django 或将 django-nose 降级到兼容版本。我建议将 Django 升级到 supported version所以你会收到错误修正和安全更新。

关于python - Django Nose 给出 "ImportError: cannot import name setup"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38438170/

相关文章:

python - Django 日志记录隐藏错误

python - 仅查询相关名称的部分对象(来自ForeignKey)

django - Nose 找不到 Django 测试

python - 使用 SWIG 编码(marshal) Python PIL 图像

python - 在 Cython 中是否可以使用 C++ 风格的内部类型定义?

python - 在python中将高斯拟合到吸收线

python - 如何从 Django request.data 获取上传图像文件的扩展名

python - 使用 pandas 从数据框中删除空间

python - 如何使用 Django + Nose 正确测试覆盖率

python - 在 Django 1.7 中测试抛出警告 : RemovedInDjango18Warning