How to avoid “WindowsError: [Error 5] Access is denied”

See RemoveDirectory documentation; “The RemoveDirectory function marks a directory for deletion on close. Therefore, the directory is not removed until the last handle to the directory is closed.” This means that if something manages to create a handle to the directory you remove (between creation and removal) then the directory isn’t actually removed and you … Read more

WindowsError [error 5] Access is denied

I solved a similar problem I had by switching to the process directory (I was trying to use inkscape) and it solved my problem import subprocess inkscape_dir=r”C:\Program Files (x86)\Inkscape” assert os.path.isdir(inkscape_dir) os.chdir(inkscape_dir) subprocess.Popen([‘inkscape.exe’,”-f”,fname,”-e”,fname_png]) Maybe switching to the process directory will work for you too.