How Can I Share a Toolbox with Python Dependencies Included?

281
3
Jump to solution
12-25-2021 03:08 PM
DarrenConly
New Contributor III

Greetings All,

I have a script that uses several python packages installable through conda but are not in the default arcgis pro environment. The packages are dbfread and sqlalchemy.

I want to share the script with other people who have Pro installed on their computers, but don't want them to have to tinker with setting up their own python environments and installing the dependencies on their own. Ideally, I want to be able to send users the toolbox, then they can just run it without them having to do any installation or messing around with conda environments.

I know this is doable if you don't use any non-default packages in the script, but is it possible to specify dependencies in a toolbox and have them installed on the fly? Or would that require something more complicated like Poetry or setuptools?

Thanks,

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

beyond Distribute a geoprocessing module—ArcGIS Pro | Documentation

If those packages have no other dependencies, then copying the folder into your distribution folder may work.  I have had success with my own packages but I haven't tried it with other people's.


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

beyond Distribute a geoprocessing module—ArcGIS Pro | Documentation

If those packages have no other dependencies, then copying the folder into your distribution folder may work.  I have had success with my own packages but I haven't tried it with other people's.


... sort of retired...
DarrenConly
New Contributor III

Thanks Dan,

To make sure I understand correctly, for my example, you're thinking I could go to the site-packages folder for the conda environment I used to develop the tool, then copy over the folders for sqlalchemy and dbfread into the folder containing the script the tool references?

I tried this and for dbfread and sqlalchemy specifically it seems to work okay (i.e., I can switch to an env without these packages installed and run my script and they import from the folders I copied over). This may work okay for this specific toolbox, but thinking more generally, if the script calls on more complex dependencies (e.g. Geopandas), then it gets hairy because not only do I need to copy over the dependency folder itself, but all of its dependencies as well.

Looks like I'll need to learn how to use setuptools()--for that I appreciate the link you shared!

0 Kudos
DanPatterson
MVP Esteemed Contributor

skip things like Geopandas, you would be better off providing documentation to the effect that this package requires X, Y and Z


... sort of retired...