import shutil
def create_dir(path):
if not os.path.exists(path):
os.mkdir(path)
else:
shutil.rmtree(path)
when I run this code it gives me permission error, even though I have access to that directory.
Also, I use Windows and I have tried running as administrator
CodePudding user response:
Check if the folder is not Read-Only.
Or you can also run command:
import os
os.system('whoami')
It will show you which user is currently registered as launching user.
CodePudding user response:
Try with ignore_errors=True,
import shutil
def create_dir(path):
if not os.path.exists(path):
os.mkdir(path)
else:
shutil.rmtree(path, ignore_errors = True)