Select to view content in your preferred language

ArcGIS Pro: python module

3689
4
02-13-2015 06:07 AM
AndreasMarth
New Contributor II

Has anyone already tried to extend ArcGIS Pro 1.0 with a python module? I have done this more or less successfully, but some things really do not work. Here some experiences and questions:

Generally I followed the ESRI help: Extending geoprocessing through Python modules—Geoprocessing and Python | ArcGIS for Professionals 

Module distribution really annoying:

It is not possible to distribute the site-package via windows installer, because the ArcGIS Pro Python installation is not found in the windows registry. So there is one workaround: copy the site-package to following path: C:\Program Files\ArcGIS\Pro\bin\Python\Lib\site-packages

This is annoying, but works. Is there a more elegant way to distribute the site-package to the arcgis pro python installation?

Toolbox integration

OK, having done this, after opening ArcGIS Pro everything is working. Through Python window I can import the module, I can use the tools in my module and the tools of my python-toolbox as well as the language specific help texts, but how can I add the toolbox to the project? In ArcMap the toolboxes of the python modules are listed automatically in the system-toolbox directory. In ArcGIS Pro the only way I found out to add the toolbox is to go choose the "Add Toolbox..." function and to step through this long path to get the toolbox: C:\Program Files\ArcGIS\Pro\bin\Python\Lib\site-packages\packagename\esri\toolboxes\...

After having done this, everything works fine, but I did not find out how it is possible to store the custom toolbox as default to the system-toolboxes, so that I do not have to load the toolbox again and again opening a new blank project. Is there a way to define the custom toolbox to be loaded by default to every new project?  

4 Replies
KevinHibma
Esri Regular Contributor

Have you considered installing the full version of Python 3.4? If you install the full version of Python, it'll show in the registry and python modules with installers will find it and install properly into it.

Install Python for ArcGIS Pro—ArcPy Get Started | ArcGIS for Professionals

0 Kudos
AndreasMarth
New Contributor II

Yes, I have tried. This works, but it is not the simple approch I am looking for. The module should be distributed over plenty of computers and also over different customers. For this approach every computer needs to have installed the whole python 3.4 version (500 MB), before being able to install the 2MB module via windows installer.

0 Kudos
GiacomoGasco
New Contributor II

I have the same problem too, after 2 years none have addressed that issue?

The toolbox is loaded in every project and i can reach it with arcpy.MyTool_alias syntax but the Toolbox is still missing from System Tools

Any update?

Thanks

0 Kudos
EricLefebvre1
New Contributor

I am also experiencing the same issue with ArcGIS Pro 2.0 and seems to be a refresh problem with the system toolbox pane.  One workaround I discovered is forcing a refresh by adding an empty python toolbox inside the product's ArcToolbox directory.  To do this I created a new toolbox in ArcPro using Insert -> Toolbox -> New Python Toolbox and gave it a name that doesn't conflict with an existing toolbox. I then copied my new toolbox file to <arcpro-install>/Resources/ArcToolBox/Toolboxes.  The next time I start ArcPro it will find the new toolbox file and force a refresh of the system toolbox pane.  Then it will look for toolboxes in your site-packages/<package>/esri folders and display them.

Once they are displayed the same problem will exist if you remove your toolbox file in site-packages/<package>/esri folder.  The underlying toolbox will be gone but it will still display in the Toolboxes pane and throw an error if you try to open it.

Another option is to store your python toolbox in a project template file and distribute the project template to other users or through your portal.  Then, instead of creating a new blank project, you can create a new project from the template and your toolbox will already be loaded in the project.  I'm still confused though with what is the preferred way since these two methods could conflict with each other where it's easy to load two tools with the same name and alias. 

0 Kudos