5

我尝试使用 djangos i18n,因此必须安装 gettext。现在,每当我尝试启动我的应用程序时,都会遇到这个尴尬的错误:

Traceback (most recent call last):
  File "/var/www/mydjangoproject/manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
  File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/management/__init__.py", line 4, in <module>
    from optparse import OptionParser, NO_DEFAULT
  File "/usr/lib/python2.7/optparse.py", line 418, in <module>
    _builtin_cvt = { "int" : (_parse_int, _("integer")),
  File "/usr/lib/python2.7/gettext.py", line 581, in gettext
    return dgettext(_current_domain, message)
  File "/usr/lib/python2.7/gettext.py", line 545, in dgettext
    codeset=_localecodesets.get(domain))
  File "/usr/lib/python2.7/gettext.py", line 480, in translation
    mofiles = find(domain, localedir, languages, all=1)
  File "/usr/lib/python2.7/gettext.py", line 437, in find
    for nelang in _expand_lang(lang):
  File "/usr/lib/python2.7/gettext.py", line 131, in _expand_lang
    from locale import normalize

  ImportError: cannot import name normalize

库 locale.py 存在,我可以导入它。Django 1.4 在 Python 2.7.2+ 下运行。有任何想法吗?

4

1 回答 1

12

我猜你的项目中有一个文件夹区域设置,其中有一个 __init__.py 文件。删除这个文件(你不需要它来翻译工作),你应该很高兴。

于 2012-06-04T00:38:29.563 回答