“Errno 13 Permission denied'bnr_code.csv'”?

时间:2018-02-11 08:36:23

标签: python django python-3.x apache2 mod-wsgi

我使用apache2和wsgi在服务器上部署了一个Django项目,它显示了一个错误,我可能知道它为什么会出现。

错误:

IOError at /
[Errno 13] Permission denied: 'bnr_code.csv'
Request Method: GET
Request URL:    http://93.188.167.63:8080/pep_learn/
Django Version: 1.10.8
Exception Type: IOError
Exception Value:    
[Errno 13] Permission denied: 'bnr_code.csv'
Exception Location: /home/pep_web/binaryDs/views.py in <module>, line 6
Python Executable:  /usr/bin/python
Python Version: 2.7.12

我尝试过一些诽谤性解决方案,如下所示:

chmod 777 pep_web /

chmod 771 pep_web /

sudo chown:www-data pep_web /

但没有任何工作

这是使用'bnr_code.csv'

的文件
AA = {"A":"1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "C":"0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "D":"0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "E":"0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "F":"0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "G":"0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "H":"0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0",
      "I":"0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0",
      "K":"0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0",
      "L":"0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0",
      "M":"0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0",
      "N":"0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0",
      "P":"0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0",
      "Q":"0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0",
      "R":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0",
      "S":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0",
      "T":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0",
      "V":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0",
      "W":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0",
      "Y":"0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1"}



line = []
seqs = ["ATTTRY","ATSSRY"]


def bnr(x):
    Des = []
    for n in x:
        Des.append(AA[n.upper()])
    des = ",".join(Des)
    return des

def Des_write(ps):
    f = open("bnr_code.csv",'w')
    for p in ps:
        a  = bnr(p)
        f.write(p+','+a+'\n')
    f.close()


Des_write(seqs)

请帮助我们可以在http://93.188.167.63:8080/pep_learn/

检查错误

1 个答案:

答案 0 :(得分:2)

不要使用文件的相对路径,请使用绝对路径。 mod_wsgi的文档中解释了此问题。

通过执行以下操作计算文件的位置:

prefs_are_none()