In the Python programming language, the “NameError: name ‘math’ is not defined” error may occur. This article introduces how to handle and resolve this error.
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> math.pi
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'math' is not defined
Solution
You need to import the module
from math import *
