AnsweredAssumed Answered

ArcPy in Created Python Modules?

Question asked by msandersAMR on Nov 15, 2017
Latest reply on Nov 15, 2017 by msandersAMR

I'm trying to use the arcpy module in functions that are within custom Python modules that I've created, but I keep getting this error:

NameError: global name 'arcpy' is not defined

How do I fix this? These modules will be used within ArcGIS, where ArcPy is already loaded.

I've tried with and without "import arcpy".

 

Example:

import arcpy

def refresher():
    ''' Refreshes map and TOC '''
    arcpy.RefreshActiveView()
    arcpy.RefreshTOC()
    return 'Refreshed map and TOC.'

Outcomes