Errno 13 Permission denied with Django on a directory I don't want to use

前提是你 提交于 2019-12-24 04:16:11

问题


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

回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/39147935/errno-13-permission-denied-with-django-on-a-directory-i-dont-want-to-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!