无法执行makemessages命令

时间:2017-09-20 07:33:02

标签: python django django-i18n

我想使用i18n,我在settings.py创建了一个语言环境目录和其他设置。

然后我在PyCharm中执行python manage.py makemessages -l zh-cn命令,但失败了。

我的回溯如下:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/management/__init__.py", line 363, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/management/__init__.py", line 296, in execute
    parser = CommandParser(None, usage="%(prog)s subcommand [options] [args]", add_help=False)
  File "/Library/Python/2.7/site-packages/Django-1.11.2-py2.7.egg/django/core/management/base.py", line 51, in __init__
    super(CommandParser, self).__init__(**kwargs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/argparse.py", line 1597, in __init__
    self._positionals = add_group(_('positional arguments'))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 569, in gettext
    return dgettext(_current_domain, message)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 533, in dgettext
    codeset=_localecodesets.get(domain))
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 468, in translation
    mofiles = find(domain, localedir, languages, all=1)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 440, in find
    for nelang in _expand_lang(lang):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 133, in _expand_lang
    from locale import normalize
ImportError: cannot import name normalize

1 个答案:

答案 0 :(得分:0)

这是因为在locale目录中有__init__.py__init__.pyc个文件,您应该删除它们。

右键单击语言环境目录 - &gt;在Finder中显示 - &gt;那么你可以看到它们,如果你只在Pycharm中显示它,你就看不到.pyc文件。

相关问题