我已經在我的centos機器中安裝了python 2.7和django 1.4,併爲我現有的項目安裝了所有依賴項。當我運行「python manage.py runserver」時,我在控制檯中獲得以下回溯。ImportError:無法導入名稱force_text
[[email protected] bv]# python manage.py runserver
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x8ddd7ec>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/site-packages/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/site-packages/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/models.py", line 6, in <module>
from debug_toolbar.toolbar.loader import load_panel_classes
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/toolbar/loader.py", line 12, in <module>
from debug_toolbar.utils.settings import CONFIG
File "/usr/local/lib/python2.7/site-packages/debug_toolbar/utils/__init__.py", line 9, in <module>
from django.utils.encoding import force_text
ImportError: cannot import name force_text
來自[docs](https://docs.djangoproject.com/en/1.5/ref/utils/#django.utils.encoding.force_text) > Django中的新增功能1.5。 – jonafato
不建議以「root」身份運行應用程序用戶:/ –
您在安裝django-debug-toolbar時沒有及時更新(當前版本沒有「utils/__ init __。py」,只是一個'utils.py')。你可以發送你的版本信息或嘗試更新到最新?根據[readme](https://github.com/django-debug-toolbar/django-debug-toolbar),它支持Django≥1.4.2和Python≥2.6.5。 – jonafato