Python – Permissions in Django makemessages are denied

Permissions in Django makemessages are denied… here is a solution to the problem.

Permissions in Django makemessages are denied

I’m trying to add i8n to a Django app, but when I execute:

(venv) user@machine:~/path/to/repo$ django-admin makemessages -l es

Throw the next error:

PermissionError: [Errno 13] Permission denied: './venv/lib/python3.5/site-packages/Jinja2-2.9.5.dist-info/'

But if I use it with instead of django-admin, it works. In the django documentation, they recommend using django-admin.

Any ideas?


Django’s documentation doesn’t really “recommend” using django-admin instead of ./ – it’s actually < a href="" rel="noreferrer noopener nofollow" > the doc states that :

Generally, when working on a single Django project, it’s easier to use than django-admin.
The command-line examples throughout this document use django-admin to be consistent, but any example can use or python -m django just as well.

The reason is:

In addition, is automatically created in each Django project. does the same thing as django-admin but takes care of a few things for you:
It puts your project’s package on sys.path.
It sets the DJANGO_SETTINGS_MODULE environment variable so that it points to your project’s file.

Note that in fact the second point is not entirely accurate – ./ is only set when not set DJANGO_SETTINGS_MODULE in your environment.

Therefore, when using django-admin, you must make sure that it finds your settings module (by setting environment variables or passing it > option via –-settings) and that the root directory of your project is in your pythonpath.

In fact, aside from the startproject command – by definition, you don’t have a ./ file yet – there’s no reason to use django-admin unless you want to explicitly use a different settings module without changing environment variables.

Related Problems and Solutions