mkdir permission denied

18,941

Have you tried using os.system with a sudo command on the operation only?

os.system("sudo mkdir /var/machine/hi")
Share:
18,941
Popcorn
Author by

Popcorn

Updated on September 15, 2022

Comments

  • Popcorn
    Popcorn over 1 year

    I'm trying to make this directory /var/machine/hi' by running this in Python:

    os.mkdir("/var/machine/hi")
    

    However, I'm getting a

    OSError: [Errno 13] Permission denied: '/var/machine/hi'
    

    I have tried the following: chmod 777 /var/machine and chmod 777 /var

    The owners for /var is root wheel

    The owners for /var/machine is root wheel

    How can I fix/debug this?