file-permissions

Removing permissions using chmod

Removing permissions using chmod Question: So for this I am trying to change only the group permissions for a file using chmod. I was able to add a executable permission to the group using permissions = os.stat(filepath) os.chmod(filepath, permissions.st_mode | stat.S_IXGRP) I added the execute permission to the group successfully using this code but I …

Total answers: 1

"Permission Denied" trying to run Python on Windows 10

"Permission Denied" trying to run Python on Windows 10 Question: Seems as though an update on Windows 10 overnight broke Python. Just trying to run python –version returned a “Permission Denied” error. None of the three updates; KB4507453, KB4506991, or KB4509096 look like they’d be the culprit but the timing of the issue is suspicious. …

Total answers: 19

How to set a files owner in python?

How to set a files owner in python? Question: Firstly is it possible to set a file’s owner with python? And if so how do you set a file’s owner with python? Asked By: Jay || Source Answers: os.chown(path, uid, gid) http://docs.python.org/library/os.html The uid and gid can be retrieved from a string by import pwd …

Total answers: 2

open() in Python does not create a file if it doesn't exist

open() in Python does not create a file if it doesn't exist Question: What is the best way to open a file as read/write if it exists, or if it does not, then create it and open it as read/write? From what I read, file = open(‘myfile.dat’, ‘rw’) should do this, right? It is not …

Total answers: 17

shutil.rmtree fails on Windows with 'Access is denied'

shutil.rmtree fails on Windows with 'Access is denied' Question: In Python, when running shutil.rmtree over a folder that contains a read-only file, the following exception is printed: File “C:Python26libshutil.py”, line 216, in rmtree rmtree(fullname, ignore_errors, onerror) File “C:Python26libshutil.py”, line 216, in rmtree rmtree(fullname, ignore_errors, onerror) File “C:Python26libshutil.py”, line 216, in rmtree rmtree(fullname, ignore_errors, onerror) File …

Total answers: 5

What user do python scripts run as in windows?

What user do python scripts run as in windows? Question: I’m trying to have python delete some directories and I get access errors on them. I think its that the python user account doesn’t have rights? WindowsError: [Error 5] Access is denied: ‘path’ is what I get when I run the script. I’ve tried shutil.rmtree …

Total answers: 7

What do I use on linux to make a python program executable

What do I use on linux to make a python program executable Question: I just installed a linux system (Kubuntu) and was wondering if there is a program to make python programs executable for linux. Asked By: clinton || Source Answers: Just put this in the first line of your script : #!/usr/bin/env python Make …

Total answers: 9