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

Solution: Import the 'S_ISREG' module

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

from stat import S_ISREG

 

For more information:
Python stat S_ISREG