You may receive PermissionError: [WinError 5] Access is denied: ‘C:\\Windows\\to_your_path’ while you use shutil.rmtree python code in windows environment.
shutil.rmtree is utility with a function that can remove directory in windows even if it contains files or subdirectories.
But what happens when you encounter WinError 5?
It may be while you use explorer.exe to enter the directory you want to delete and go back to the parent folder in some cases.So, it may be explorer.exe occupy the directory handles while you use explorer to check it and go back and run the python script.
Solution: Just close the explorer window which contains the history of the directory you want to remove.