PYTHON_EGG_CACHE, MySQL and permission denied error

The most annoying problem I've ran into so far when building out a Django build is handling this error:

[Errno 13] Permission denied: '/.python-eggs'

The '/.python-eggs' part maybe in a different location for you, but the problem is the same. Django is saying that it cannot access the folder where it wants to unpack its eggs. This is fine, except that even if you change the permissions on that folder, it doesn't work. The Django documentation states that you should do two things:

1) place this particular line of code outside the Location block of your .conf file, like so:

PythonInterpreter my_django
PythonImport /path/to/my/project/file.py my_django

And 2) add a file to your project directory (same as above, file.py), with this in it:

import os
os.environ['PYTHON_EGG_CACHE'] = '/some/directory'

Now, this may work for you, but it did not work on CentOS running Plesk. What I had to do was create a new folder, django_dump, change it's permissions to 'apache:apache', then place this inside the Location tag that houses the project:

SetEnv PYTHON_EGG_CACHE /django_dump

I restarted Plesk, then Apache and all was well.