Skip to main content
Added content from this answer https://stackoverflow.com/a/25172642/119775 which really should have been an edit to the accepted answer in the first place
Source Link
Jean-François Corbett
  • 38.7k
  • 30
  • 145
  • 192
import shutil shutil.rmtree('/folder_name') 

Standard Library Reference: shutil.rmtree.

By design, rmtree fails on folder trees containing read-only files. If you want the folder to be deleted regardless of whether it contains read-only files, then use

shutil.rmtree('/folder_name', ignore_errors=True) 
import shutil shutil.rmtree('/folder_name') 

Standard Library Reference: shutil.rmtree.

import shutil shutil.rmtree('/folder_name') 

Standard Library Reference: shutil.rmtree.

By design, rmtree fails on folder trees containing read-only files. If you want the folder to be deleted regardless of whether it contains read-only files, then use

shutil.rmtree('/folder_name', ignore_errors=True) 
Source Link
ddaa
  • 54.7k
  • 8
  • 54
  • 59

import shutil shutil.rmtree('/folder_name') 

Standard Library Reference: shutil.rmtree.