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

Solution: Import the 'arcpy' module

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

import arcpy

 

For more information:
Python arcpy