AnsweredAssumed Answered

How do we import a script that defines a function using arcpy without a NameError?

Question asked by mjdmorgan on Jul 27, 2017
Latest reply on Aug 9, 2017 by CDow-esristaff

I am trying to run a script called in the Arcmap python window (version 10.4) that imports another script in the same directory that defines field mappings (it has a single def statement). My understanding is that both scripts should import arcpy, because both are using arcpy functions (field map objects and management geoprocessing methods), but running the first script results in an error: "NameError: global name 'arcpy' is not defined," as it imports the second script.


Should just 1 script import arcpy? Should I set PYTHONPATH in the OS (Windows 10)? What kinds of things should I be looking at to be able to use the function definition in the second script in my first ("main") script? Thanks.