Python + Mac: os.remove = Operation not permitted?
It's simple: I have created a folder on the desktop that I later want to remove. But when I run the script, I get this:
Processing order from queue: 002508Copying order to desktop: /Volumes/process/002508 -> /Users/Michael/Desktop/002508 Traceback (most recent call last): File "./process-queue.py", line 64, in <module> prep_desktop() File "./process-queue.py", line 25, in prep_desktop os.remove(thefolder)OSError: [Errno 1] Operation not permitted: '/Users/Michael/Desktop/TheFolder'
The file is owned by Michael:staff, and I can delete it manually by dragging into the trash can. I can delete it with rm -vf. I just can't delete it from within Python.
A side note: The single or double quotes can be used interchangeably. They have the same functionality.
My +1 for shutil.rmtree, only the folder must not be a symblolic link. The os.rmdir works only for the empty directory. The os.remove can remove only the files.
My +1 for shutil.rmtree, only the folder must not be a symblolic link. The os.rmdir works only for the empty directory. The os.remove can remove only the files.