How to Solve NameError: name 'setlocale' is not defined -- locale
Solution: Import the 'setlocale' module
To Solve the error, add the following line to the top of your code.
from locale import setlocale
For more information:
Python locale setlocale