2017-09-20 1 views
1

Je souhaite utiliser i18n et j'ai créé un répertoire de paramètres régionaux et d'autres paramètres dans settings.py. Puis j'ai exécuté la commande python manage.py makemessages -l zh-cn dans mon PyCharm, mais j'ai échoué.Impossible d'exécuter la commande makemessages

Mon retraçage est ci-dessous:

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 

Répondre

0

Il est est parce que dans votre répertoire locale il y a __init__.py et __init__.pyc fichiers, vous devez les supprimer.

Faites un clic droit sur le répertoire des paramètres régionaux -> Révéler dans le Finder -> alors vous pouvez les voir, si vous ne l'affichez que dans le Pycharm, vous ne pouvez pas voir le fichier .pyc.

+0

Probablement la bonne réponse, mais prendre soin d'expliquer pourquoi? Ce n'est peut-être pas si évident pour le PO. – spectras