How to Solve NameError: name 'rmtree' is not defined -- shutil

Erorr: name 'rmtree' is not defined

NameError: name 'rmtree' is not defined

Solution: Import the 'rmtree' module

# Add the following line to the top of your code
from shutil import rmtree

 

For more information:
shutil rmtree