我正在尝试启动并运行Django应用程序.这些库有点过时(目前在Django 1.4上).
当我尝试使用python 2.6时,我或多或少地工作了,但是当我使用python 2.7更改为virtualenv时,我得到错误:
Unhandled exception in thread started byTraceback (most recent call last): File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run autoreload.raise_last_exception() File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/__init__.py", line 18, in setup apps.populate(settings.INSTALLED_APPS) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate app_config = AppConfig.create(entry) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/django/apps/config.py", line 90, in create module = import_module(entry) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "/home/colin/software/virtualenvs/barshool/lib/python2.7/site-packages/transmeta/__init__.py", line 7, in from django.utils.datastructures import SortedDict ImportError: cannot import name SortedDict
我用相同的需求文件设置了virtualenvs.
可能导致此问题的版本之间有什么区别?
SortedDict
在Django 1.9中删除了.确保在新虚拟环境中安装了与旧版本相同的Django版本.
如果它是您自己使用的代码SortedDict
,那么长期修复就是更新要使用的代码collections.OrderedDict
,这是在Python 2.7中添加的.在您的情况下,看起来导入错误来自第三方应用程序,您必须更新或替换它以使代码与Django 1.9一起使用.