I want to share a simple way that works for me.
I just created a function that changes the write permission mode of a file and then deletes it using os.remove :
import stat
then when using rmtree add it to the onerror parameter:
import shutil shutil.rmtree(desiredpath, onerror = remShut)
Hope this helps someone with the same issue as me.
source share