2

I have this error appearing in my Django app on my production server :

[Errno 13] Permission denied: '/var/www/.config'

I never asked to access to this unexisting file or directory in my code. The server is running in a different directory defined in my httpd.conf and I haven't defined the use of any /var/www/ elements in my Django settings.

In my case I'm using the biopython library with Django :

from Bio import Entrez

Entrez.email = "my@email"

handle = Entrez.efetch("taxonomy", id="123, 1")
records = Entrez.parse(handle)

This code is working in a python console on the server. But the instruction Entrez.parse(handle) return the error in a Django environment.

I haven't seen any instruction asking to write or open anything in the source code of the function so it seems to be a problem with Django?

Is it a configuration problem? A background Django function trying to access to a file when I call a specific function?

My configuration :

  • Python 3.3
  • Django 1.8
  • Biopython 1.67
Thibaut Guirimand
  • 851
  • 10
  • 33

2 Answers2

2

In facts, Entrez.parse is calling the DataHandler objects. This objects try to write in the user directory with something like :

home = os.path.expanduser('~')
directory = os.path.join(home, '.config', 'biopython')
local_xsd_dir = os.path.join(directory, 'Bio', 'Entrez', 'XSDs')
os.makedirs(local_xsd_dir)

Because biopython user is the httpd user, the home directory is /var/www/.

The solution is here to allow apache to write into /var/www or to move it to a different place.

Thibaut Guirimand
  • 851
  • 10
  • 33
  • Good answer, +1. I just looked at the source, and there is no way to override this behavior externally - i.e., you can't just run `from Bio.Entrez.Parser import DataHandler; DataHandler.local_storage_dir = "/tmp/biopython"` or something similar. I think I'll file a bug. – MattDMo Aug 25 '16 at 16:07
  • Check out and/or track [this issue](https://github.com/biopython/biopython/issues/918) on Github if you're interested. – MattDMo Aug 25 '16 at 16:31
  • What do you mean with move it to a different place? – Cheluis Feb 14 '17 at 15:01
1

Restart the server or restart the service of django.
That is important, because the services in the background have to know the new location of the configuration.
I guess it works on python, because the library is loading the actual settings and the background service is using the old one.

Hope I could help