I have a simple custom script tool that I want to share within our GIS office. The tool works fine from in my Pro application. Both the tool and the stand alone script it points to are stored in a network folder/UNC path that everyone has access to. When ran from another instance of Pro, whether from my colleague's PC or a dedicated box I remote log into, the tool throws this error:
Traceback (most recent call last):
File "\\uncpathtothescript\LayoutToPDF_Tool.py", line 26, in <module>
current_aprx = arcpy.mp.ArcGISProject(os.path.join(env, file))
File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\_mp.py", line 337, in __init__
self._arc_object = arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True))
OSError: \\uncpathtoproproject\COUNTY_BOARD_A.aprx
Failed to execute (LayoutToPDFs).I haven't debugged other than running the tool on different machines. I've read you can share to Enterprise Portal, but I'm not interested in that. If I can simply share to a network folder so anyone can just simply open it immediately from their system that would be best.
The tool exports layouts to PDFs.
#-------------------------------------------------------------------------------
# Name: LayoutToPDF_Tool.py
# Purpose: Exports APRX layout to PDF.
#
# Author: jpilbeam
#
# Created: 13/08/2024
# Copyright: (c) Will Co GIS
# Licence: <WillCo GIS>
#-------------------------------------------------------------------------------
import arcpy, os
#workspace folder
env = arcpy.env.workspace = arcpy.GetParameterAsText(0)
#print the number of aprx files in the workspace folder
aprxlist = arcpy.ListFiles("*.aprx")
arcpy.AddMessage("Currently {0} maps to be updated:\n".format(len(aprxlist)))
#Loop through folder and list APRXs
for dirName, subdirList, fileList in os.walk(env):
for file in fileList:
if file.endswith(".aprx"):
current_aprx = arcpy.mp.ArcGISProject(os.path.join(env, file))
for lyt in current_aprx.listLayouts():
#export APRXs to PDFs
lyt.exportToPDF(f'{env}\{lyt.name}')
arcpy.AddMessage("{} to PDF".format(lyt.name))
# current_aprx.save()
del current_aprx
print("----done----")