简体   繁体   English

尝试写入文件的权限被拒绝

[英]Permission denied on trying to write file

I am a python/Django newbie. 我是python / Django新手。 I am creating folders in my view using: 我正在使用以下方法在我的视图中创建文件夹:

os.makedirs(path)

The path is different for each file and depends on username and filename combination. 每个文件的路径都不同,并且取决于用户名和文件名的组合。 On trying to write a file in this folder, I get this error: 尝试在此文件夹中写入文件时,出现以下错误:

IOError at /view_name/
[Errno 13] Permission denied: u'<filepath>'

This is on my windows system. 这是在我的Windows系统上。 Even on trying to change permission to write from read only, doesn't changes it(its default and only attribute for folders in windows). 即使尝试更改从只读写入的权限,也不会更改它(它是Windows中文件夹的默认和唯一属性)。 What should I do? 我该怎么办?

One possibility is that the directory already exists, which, according to this should raise an error. 一种可能性是,该目录已经存在,其中,根据应该产生一个错误。

It is also possible that the directory is used in some other program, like explorer, and that needs to be closed first. 该目录也有可能在其他程序(例如资源管理器)中使用,并且需要首先关闭。

A third option I can think of is that the default permissions for a directory on your system don't allow reading by a user, in which case your program would need to be run as an administrator or use the win32security module from pywin32 to manually set permissions for the directory(although that may also not work if you don't have permission to change permissions). 我可以想到的第三个选择是,系统上目录的默认权限不允许用户读取,在这种情况下,您的程序将需要以管理员身份运行或使用pywin32中win32security模块进行手动设置目录的权限(尽管如果您没有更改权限的权限,也可能不起作用)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM