How to Solve NameError: name 'cgi' is not defined

Solution: Import the 'cgi' module

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

import cgi

 

For more information:
Python cgi