ExportToPDF crash without error on ArcGIS Server python

519
6
Jump to solution
07-04-2024 02:48 AM
PierreloupDucroix
Frequent Contributor

Hello,

I try to export a PDF with a scheduled task that runs in an arcgis server's server.

The ExportToPDF line of code crashes without any error with the python from ArcGIS Server, but works great with the python from ArcGIS Pro in other environments...

Here is a simple code test I made, it's crashing in the last line :

 

import arcpy
aprx = arcpy.mp.ArcGISProject(r"D:\path...\exportToPDF.aprx")
m = aprx.listMaps("Map")[0]
layout ="Test"
lyt = aprx.listLayouts(layout)[0]
mf = lyt.listElements("mapframe_element", "WEBMAP_MAP_FRAME")[0]
extent = arcpy.Extent(446998.96875,  214866.71875, 446579.875, 215163.046875)
mf.camera.setExtent(extent)
m.defaultCamera = mf.camera
lyt.exportToPDF(out_pdf=r"D:\path...\out.pdf")

 

 

Working with Pro 3.3

Not working with Server 11.3

Any idea ?

 

0 Kudos
1 Solution

Accepted Solutions
PierreloupDucroix
Frequent Contributor

I found the solution.

I tried to install ArcGIS Pro on the server to see if there was any difference, and the setup required installing Microsoft Edge WebView2 RuntimeInstaller X64.

Finally, it now works with the ArcGIS Server's python and I think it is the installation of the webview and not Pro that solved it.

I think ArcGIS Enterprise Setup should also require this webview to be installed...

View solution in original post

0 Kudos
6 Replies
DanPatterson
MVP Esteemed Contributor

the path exists?  (line 10) and you can write to it?

Same python version? and api for python version?


... sort of retired...
0 Kudos
PierreloupDucroix
Frequent Contributor

Here is a screenshot with a cloned environment from Pro, version 3.11.8 and PDF is written :

PierreloupDucroix_0-1720126871105.png

and here with Server's python, same version and nothing happens :

PierreloupDucroix_1-1720126933401.png

I also tried

try:
    print("try")
    mf.exportToPDF(out_pdf=r"C:\Temp\out.pdf")
except exception as e:
    print(e)

but no exception is returned

0 Kudos
DanPatterson
MVP Esteemed Contributor

Tech Support is your best option.

related post

Solved: Python Script succeeds in IDLE(ArcGIS Pro 2.9.0) b... - Esri Community

so there are documented issues along this vein


... sort of retired...
0 Kudos
PierreloupDucroix
Frequent Contributor

I found the solution.

I tried to install ArcGIS Pro on the server to see if there was any difference, and the setup required installing Microsoft Edge WebView2 RuntimeInstaller X64.

Finally, it now works with the ArcGIS Server's python and I think it is the installation of the webview and not Pro that solved it.

I think ArcGIS Enterprise Setup should also require this webview to be installed...

0 Kudos
DanPatterson
MVP Esteemed Contributor

ArcGIS Pro 3.3 system requirements—ArcGIS Pro | Documentation

there it is

WebView2 Runtime

Microsoft Edge WebView2 Runtime version 117 or later is required. If it is not already installed on the machine, use the Evergreen Bootstrapper or Evergreen Standalone Installer from Microsoft.

Note:
A per-machine installation (the default) of ArcGIS Pro requires a per-machine installation of WebView2 Runtime. To do this, right-click the WebView2 installer and click Run as administrator.


... sort of retired...
0 Kudos
PierreloupDucroix
Frequent Contributor

Thanks, Dan,

WebView2 is not part of the ArcGIS Enterprise or Server requirements (https://enterprise.arcgis.com/en/system-requirements/latest/windows/arcgis-server-system-requirement...)

but I understand that any arcpy function using an APRX will need the requirements of ArcGIS Pro and not only ArcGIS Server.

0 Kudos