AnsweredAssumed Answered

arcpy.AddToolbox - how to specify relative path for multiple ArcGIS versions

Question asked by rastrauch Champion on Nov 24, 2015
Latest reply on Nov 24, 2015 by Dan_Patterson

I have a script that requires me to use arcpy.AddToolbox, which I currently have set up for 10.3

arcpy.AddToolbox(r"C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcToolbox\Toolboxes\Spatial Analyst Tools.tbx")


How can I query the version and make the path relative so it will work for other versions, e.g. 10.2 or 10.4 (eventually).


BTW, I thought

import arcpy
from import *

would be enough for me to not have to add the toolbox, but that didn't work.  If anyone knows why, I'd be curious.  Without the full toolbox, it was crashing on     arcpy.ExtractValuesToPoints_sa(randomTemp, elevRaster, randomPtSet, "NONE", "VALUE_ONLY")




cross-post python snippets  Developer Communities