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

Solution: Import the 'xbmcgui' module

# Add the following line to the top of your code
import xbmcgui

 

For more information:
Python xbmcgui