I have made a project that creates map prints from different layouts in ArcGIS Pro and published them as Services in ArcGIS Server 10.9.1.
The python code obviously uses a reference to an ArcGIS Pro project file (.aprx) to reference the layouts further. This have worked fine so far, but lately I changed some of the layouts in the .aprx file and now I always get the OSError, with the filepath specified.
Well that means, only when I run the tool through ArcGIS Server. When I run the tool through ArcGIS Pro directly or via the Python interpreter in PyCharm it works fine. And also, before I changed the .aprx everything worked fine in ArcGIS Server as well.
Here is some of the code used to reference the file:
exceptionMsg = "";
arcgisProjectFile = None
pth = r"C:/GPTools/files/GPTools.aprx"
try:
arcgisProjectFile = mp.ArcGISProject(pth)
except Exception as ex:
template = "En 'Exception' av typen {0} skjedde under genereringen. Kodemeldinger:\n{1!r}"
exceptionMsg = template.format(type(ex).__name__, ex.args)
spatialReference = arcpy.SpatialReference(25832)
I've tried
Nothing seems to make a difference, I only get the same:
OSError: C:\\GPTools\\files\\GPTools.aprx
I encountered this oserror trying to exportToPDF. I found it was because the folder I was exporting, didn't exist and as such the serviceaccount running the process, didn't have access. I needed the serviceaccount to mkdir first
Unfortunately none of the error handling such as arcpy.Exists(), os.path.exists() and os.path.isfile() pointed me to this