我几天前发布了类似的问题,但是那个时候它只是通过用绝对路径替换手动路径解决了这次我再次坚持类似的问题而且我尝试过很多东西,但没有任何工作。我该如何解决这个问题
这是我的观点,即抛出错误:
def Pep_Str_Des(request):
#return render(request, 'PepStructure/Structure.html', {})
if request.method == 'POST':
form = Pep_str_Des(request.POST)
if form.is_valid():
val = form.cleaned_data['Input_peptide']
pep_list = []
for v in val.split(','):
if len(val.split(',')[0]) <= 17:
if len(val.split(',')[0]) == len(v):
pep_list.append(v)
print v
df = pd.DataFrame({'col_1':pep_list})
print df
#file_path = os.path.join(os.path.dirname(__file__),'Input.csv')
df.to_csv(os.path.join(os.path.dirname(__file__),'Input.csv'), index = False)
os.environ['Input_file'] = os.path.join(os.path.dirname(__file__),'Input.csv')
os.environ['out_file'] = os.path.join(os.path.dirname(__file__),'Out_file.csv')
os.environ['cmds'] = os.path.join(os.path.dirname(__file__),'Structure_bassed_Descriptor_generation.py')
os.system("python $cmds -p $Input_file -d $out_file")
f_ns = glob.glob(os.path.join(os.path.dirname(__file__),'strs')+"/*.pdb")
for f in f_ns:
os.remove(f)
f_ns = glob.glob(os.path.join(os.path.dirname(__file__),'strs')+"/*.sdf")
for f in f_ns:
os.remove(f)
return render(request, 'Structure_Descriptor/Out.html', {'val':val} )
else:
Input_peptide = 'ELIKAHLPDVALLDYRM,RYMKYLTGCAKLFRQGY,TGRVPLDQMSWVTPARW,IVKAVLDCAKGRDVVAP,QTRFANAPIRWLHADIM,GYRPDPATGAVNVPIYA'
form = Pep_str_Des(initial={'Input_peptide': Input_peptide})
return render(request, 'Structure_Descriptor/Des.html', {'form':form})
错误:
IOError at /Pep_Str_Des/
[Errno 13] Permission denied: '/home/pep_web/Structure_Descriptor/Input.csv'
Request Method: POST
Request URL: http://93.188.167.63:8080/pep_learn/Pep_Str_Des/
Django Version: 1.10.8
Exception Type: IOError
Exception Value:
[Errno 13] Permission denied: '/home/pep_web/Structure_Descriptor/Input.csv'
Exception Location: /usr/lib/python2.7/dist-packages/pandas/io/common.py in _get_handle, line 356
Python Executable: /usr/bin/python
Python Version: 2.7.12
Python Path:
['/home/pep_web',
'/usr/local/lib/python2.7/dist-packages/Django-1.10.8-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PILcompat',
'/usr/lib/python2.7/dist-packages/gtk-2.0']
Server time: Sat, 17 Feb 2018 09:49:35 +0000
答案 0 :(得分:0)
经过艰苦的努力,我能够解决问题,如下所示......
首先,我从文件夹中删除了所有权限......
chmod 000 pep_web
然后
chmod -R 777 pep_web
像魔术一样为我工作..
...谢谢