I'm creating a new environment setup script for my organization, but am having problems with installing Django. After executing pip install Django==1.4.19
under virtualenv a test that requires localization support yields:
...
File "/home/ubuntu/venvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 105, in activate
return _trans.activate(language)
File "/home/ubuntu/venvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 194, in activate
_active.value = translation(language)
File "/home/ubuntu/venvs/meynv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 184, in translation
current_translation = _fetch(language, fallback=default_translation)
File "/home/ubuntu/venvs/myenv/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 147, in _fetch
res._info = res._info.copy()
AttributeError: 'NoneType' object has no attribute '_info'
Diving into Django's trans_real.translation()
function reveals that the error comes from trying to find catalog django
under ~/venvs/myenv/local/lib/python2.7/site-packages/django/conf/locale
, however that directory contains no translation files or LC_MESSAGES
directory:
(myenv)ubuntu@ubuntu:~$ ls ~/venvs/myenv/local/lib/python2.7/site-packages/django/conf/locale/en/
total 12
-rw-rw-r-- 1 ubuntu ubuntu 1637 Jun 22 13:51 formats.py
-rw-rw-r-- 1 ubuntu ubuntu 1094 Jun 22 13:51 formats.pyc
-rw-rw-r-- 1 ubuntu ubuntu 0 Jun 22 13:51 __init__.py
-rw-rw-r-- 1 ubuntu ubuntu 149 Jun 22 13:51 __init__.py
Instead, the .po and .mo files can be found under the virtualenv's root:
(myenv)ubuntu@ubuntu:~$ ls -l ~/venvs/myenv/django/conf/locale/en/LC_MESSAGES/
-rw-rw-r-- 1 ubuntu ubuntu 356 Jun 22 13:51 django.mo
-rw-rw-r-- 1 ubuntu ubuntu 21041 Jun 22 13:51 django.po
In general the directory ~/venvs/myenv/local/lib/python2.7/site-packages/django
contains no .po- or .mo-files, and all of them can be found under ~/venvs/myenv/django
in appropriate subdirectories.
Pip version is 7.0.3, and if I downgrade it to version 6.1.1 (which we have been using earlier), the translation files can be (properly?) found under site-packages/django
and everything works.
What could cause this pecular behaviour with newer pip?
UPDATE
It appears also djcelery
package is affected by this. Its .html-files (and only those) are installed under virtualenv's root, while the rest is under site-packages/djcelery
:
/home/ubuntu/venvs/myenv/djcelery/
+-- templates
+-- admin
| +-- djcelery
| +-- change_list.html
+-- djcelery
+-- confirm_rate_limit.html
Is there some common denominator between these html-files and django's .po/.mo-files?
Not exactly an elegant fix, but if you just need to get your project up and running and downgrading pip is not an option, a symlink will do it: