Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name normalize

I tried to use djangos i18n and therefor had to install gettext. Now I'm getting this awkward error any time I try to start my application:

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

The library locale.py is present and I can import it. Django 1.4 is running under Python 2.7.2+. Any Ideas?

like image 673
PenthousePauper Avatar asked Jun 03 '12 23:06

PenthousePauper


1 Answers

I guess you have somewhere inside your project a folder locale with an __init__.py file in it. Delete this file (you don't need it for translation to work) and you should be good to go.

like image 77
Maccesch Avatar answered Oct 13 '22 03:10

Maccesch