Run Custom Geoprocessing Tool Using New Python Environment

751
2
Jump to solution
02-15-2022 12:58 PM
Labels (1)
KeonMonroe
New Contributor III

I need to publish a geoprocessing tool as a service using ArcGIS Pro. This tool requires a Python library called 'xlsxwriter', so I created a new Python environment (by cloning the default). I successfully activated the Python environment in my .aprx project, then ran the custom geoprocessing tool. The tool fails to run because it tries using the default Python interpreter, so the package is missing. 

Also it appears after activating to the desired Python environment (not default), this option never actually saves in the .aprx file. I activate it, save and restart - the chosen environment always reverts to default. 

I have also tried editing the Geoprocessing options' script editor to the new environment's python.exe. That also fails to run the tool using the correct environment

How can I force Pro to run the project using the desired Python environment? I can't publish the service until the tool runs successfully in Pro. I am using Pro version 2.8.1

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

you could package it with your tools, it isn't very big

jmcnamara/XlsxWriter: A Python module for creating Excel XLSX files. (github.com)

the package doesn't need to be in the environment, just accessible from the script that imports it

Create geoprocessing modules—ArcGIS Pro | Documentation


... sort of retired...

View solution in original post

2 Replies
DanPatterson
MVP Esteemed Contributor

you could package it with your tools, it isn't very big

jmcnamara/XlsxWriter: A Python module for creating Excel XLSX files. (github.com)

the package doesn't need to be in the environment, just accessible from the script that imports it

Create geoprocessing modules—ArcGIS Pro | Documentation


... sort of retired...
KeonMonroe
New Contributor III

Thanks. I hadn't considered just importing it within the script itself.

0 Kudos