locale name conflict (deploy issue)

445 views
Skip to first unread message

dcoy

unread,
Aug 16, 2008, 7:12:39 AM8/16/08
to Django users
Hi,

I'm trying to deploy my django project to my VPN (CentOS 5 python
2.4). I'm having ALL kinds of issues, nothing seems to work after
following the steps in the installation documentation at
djangoproject.com. Anyways now I've tracked down an issue that I don't
really know how to solve:

When running "# python manage.py" at my django project root I get:
.....
File "/usr/lib/python2.4/gettext.py", line 128, in _expand_lang
from locale import normalize
ImportError: cannot import name normalize

So after some investigation I realize that it is my locale directory
under $PROJECTPATH that screw things up since it is first in the
sys.path(s).

My locale is set up according to django i18n doc as
# $PROJECTPATH/locale/<language>/LC_MESSAGES/django.(po|mo)
but when gettext.py is trying to import from locale it is looking at
my project locale, not in the /usr/lib/python2.4/locale.py.

I confirmed this by temporarily renaming my $PROJECTPATH/locale.

Can someone help me out? I don't know the correct course to take here.

Thanks,
Calle

dcoy

unread,
Aug 16, 2008, 7:47:52 AM8/16/08
to Django users
I figured this problem should occur in my windows environment as well.
So I did some tests but I never got that import problem.
In sys.path on windows the current dir is first (same on linux) so
python should start to look in the current dir for "locale". But
somehow the problem only arises on linux (which is running python 2.4,
windows is running 2.5, could that be it??)

Prairie Dogg

unread,
Aug 24, 2008, 1:14:29 PM8/24/08
to Django users
I ran into this problem as well when I upgraded to the most recent
django trunk. I found out about it because my tests failed the
following error:

from locale import normalize
ImportError: cannot import name normalize

Whoever is writing the patch for ticket #5494 (http://
code.djangoproject.com/ticket/5494)
_may_ want to take this into consideration.

Malcolm Tredinnick

unread,
Aug 24, 2008, 1:29:18 PM8/24/08
to django...@googlegroups.com

On Sun, 2008-08-24 at 10:14 -0700, Prairie Dogg wrote:
> I ran into this problem as well when I upgraded to the most recent
> django trunk. I found out about it because my tests failed the
> following error:
>
> from locale import normalize
> ImportError: cannot import name normalize

So you've kind of hijacked the original thread here, since this is a
separate issue (I've changed the topic for that reason).

What version of Python are you using on which OS/platform? The
locale.normalize method is certainly in Python 2.3 by default (and later
versions). Are you running some kind of cut-down Python install?

Regards,
Malcolm


msaelices

unread,
Aug 24, 2008, 3:01:22 PM8/24/08
to Django users
Maybe you have an __init__.py inside locale directory?

dcoy

unread,
Aug 30, 2008, 10:00:24 AM8/30/08
to Django users
oh sh*t, that was it!

So stupid :)

Thanks!

Prairie Dogg

unread,
Aug 31, 2008, 3:25:14 AM8/31/08
to Django users
Sorry about the thread hijack there, I mistakenly thought the
problems were related.

I'm using Python 2.5 on Ubuntu Hardy. It seems to me that the
issue is the project locale directory is in my project folder.

The fact that the locale folder for my project is called
"locale" is causing a name space collision in the line:

from locale import normalize

I suffer from that newbie problem of not knowing what the
best / standard default configurations are. The locale
directory was placed in the project root by

./manage.py makemessages -a

So I was kinda loathe to move it out of there.

Thanks so much for taking the time to look at the issue,
I apologize if this is a simple problem with a simple
solution...


On Aug 24, 1:29 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
Reply all
Reply to author
Forward
0 new messages