How do I make my python script portable for ArcMap users?

530
1
11-21-2018 12:27 PM
ChristopherHigham1
New Contributor II

Here is the situation: I am using ArcGis Pro to create a tool, but my associate wants to use the tool in ArcMap 10.6. I ensured that my python was written so it could be interpreted by both ArcGIS Pro 2.2 and ArcMap 10.6 by creating a separate tool in the toolbox, but the second was created in ArcMap. Both tools used the same python file, and both functioned properly. I thought I embedded the python file in both tools.

I troubleshooted by sending the toolbox to another computer via email. The script tool I created in ArcGIS Pro for ArcGIS Pro works. The script tool I created in ArcMap for ArcMap gave me an error that the file does not exist. 

My thought is that when I embedded the python file in each script tool, the tool for ArcGIS Pro kept the file somehow, but the ArcMap tool did not. Maybe I am supposed to store the Python file in the toolbox itself to make it portable for the ArcMap script tool? This is my source for why I suspect this is the case: http://desktop.arcgis.com/en/arcmap/latest/analyze/sharing-workflows/embedding-scripts-and-password-...

However, if this is the problem, I do not know how to save the python file in the toolbox. If it not the problem, I don't know what to do to make my script tool for an ArcMap user more portable. 

Thoughts?

0 Kudos
1 Reply
DanPatterson_Retired
MVP Emeritus

If you are using relative paths for the tool and keep your script in same folder (or relative to it) as the *.tbx, then it should work.  If the script is located in another location, then it will fail.  The easiest way is to put your script and *.tbx in the same location.

Do also note, that don't taint the arcmap toolbox by messing with in Pro

0 Kudos