How to Solve NameError: name 'S_ISDIR' is not defined -- stat

Solution: Import the 'S_ISDIR' module

To Solve the error, add the following line to the top of your code.

from stat import S_ISDIR

 

For more information:
Python stat S_ISDIR