问题描述
我的生产服务器上的Django应用中出现此错误:
I have this error appearing in my Django app on my production server :
我从没问过要在我的代码中访问这个不存在的文件或目录.该服务器正在我的httpd.conf中定义的其他目录中运行,并且我尚未在Django设置中定义任何/var/www/元素的使用.
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.
在我的情况下,我将biopython库与Django一起使用:
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)
此代码在服务器上的python控制台中运行.但是指令Entrez.parse(handle)
在Django环境中返回错误.
This code is working in a python console on the server. But the instruction Entrez.parse(handle)
return the error in a Django environment.
这是配置问题吗?当我调用特定函数时,后台Django函数试图访问文件吗?
Is it a configuration problem? A background Django function trying to access to a file when I call a specific function?
我的配置:
- Python 3.3
- Django 1.8
- Biopython 1.67
推荐答案
实际上,Entrez.parse
正在调用 DataHandler 对象.该对象尝试使用以下内容在用户目录中写入内容:
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)
由于biopython用户是httpd用户,因此主目录为/var/www/.
Because biopython user is the httpd user, the home directory is /var/www/.
此处的解决方案是允许 apache 写入/var/www 或将其移动到其他位置.
The solution is here to allow apache to write into /var/www or to move it to a different place.
这篇关于Errno 13我不想使用的目录上的Django拒绝了权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!