ImportError: cannot import name normalize

匿名 (未验证) 提交于 2019-12-03 01:22:02

问题:

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?

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!