[英]Chmod in Python - [Errno 1] Operation not permitted
I'm trying to modify an application in my /Applications folder on OS X. I need to get read and write permissions, so I currently have:我正在尝试修改 OS X 上 /Applications 文件夹中的应用程序。我需要获得读写权限,因此我目前拥有:
os.chmod(appDir, 0644)
where appDir is the directory of my app.其中 appDir 是我的应用程序的目录。 However, whenever I run the program, I get the error:但是,每当我运行程序时,我都会收到错误消息:
OSError: [Errno 1] Operation not permitted: '/Applications/Simplenote.app'
I would try sudo , but how would you enter the password through Python?我会尝试sudo ,但是您将如何通过 Python 输入密码? (this is a Python script by the way) (顺便说一下,这是一个 Python 脚本)
Any help is appreciated.任何帮助表示赞赏。
If you are trying to run the script from a web site, change the target folders/files to be owned by the web user, eg www-data.如果您尝试从网站运行脚本,请将目标文件夹/文件更改为由网络用户拥有,例如 www-data。 sudo chown www-data * -R
That fixed it for me. sudo chown www-data * -R
为我解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.