Is This Content Helpful?
We're glad to know this article was helpful.
Some organizations keep a shared repository of custom Python scripts and make them accessible by adding the path to the shared directory to the Windows Python path variable for each client computer running ArcMap.
For example, \\server\folder\fibo.py contains a function called fib() that returns the Fibonacci sequence. Proper configuration allows for ArcGIS to successfully execute the following:
>>> from fibo import fib >>> fib(10)
The same functionality can be achieved in ArcGIS Pro with the proper configuration.
A .pth file is used by ArcGIS Pro to determine which modules are included. This can be altered to include custom paths, and only needs to be done once (per computer or conda environment).
import sys; sys.path.append(r"\\server\folder\")This script can be verified (or troubleshoot the syntax) by entering the following command into Python Command Prompt, or by attempting custom local module imports.
python -c "import sys; print('\n'.join(sys.path))"
myPythonModules = r'\\server\scripts' sys.path.append(myPythonModules) import myutils # a Python file within myPythonModules