Hello everyone,
I am trying to upload a map service every night, and it was working without any issues until I had to uninstall and reinstall ArcGIS Pro. Since then, the process has been crashing with the following error message:
arcgisscripting.ExecuteError: ERROR 001269: Compressing the service definition failed.
Failed to execute (StageService).
Steps I have tried:
1. Saved the service draft and service with unique names, but the process still failed.
2. Signed into the portal before starting the process, but the same error occurred.
3. Tried publishing the service directly from ArcGIS Pro, and it worked successfully.
4. Created the .sddraft file from ArcGIS Pro and then used it in a Python script, but it failed with the same error.
I took help from the documentation:
https://pro.arcgis.com/en/pro-app/3.4/arcpy/sharing/mapimagesharingdraft-class.htm
Here is my code:
For ERROR 001269 (Compressing the service definition failed) after a Pro reinstall, it’s usually one of these:
Path/permissions issue on the output folder
Staging is writing temp + compressing. UNC paths sometimes fail depending on your Pro / service account context. Try staging to a local folder (e.g., C:\temp\publish\) and then copy/upload.
Corrupt temp/caches after reinstall
Clear Pro + ArcPy staging caches:
Delete contents of %TEMP%
Also check Pro sharing scratch (often under your user profile).
Mixed Pro/ArcPy environment or missing components
After reinstall, the ArcGIS Pro Python environment can be out of sync. Confirm you’re running the script with the Pro conda env (arcgispro-py3) that matches the installed Pro version.
Wrong upload target / inconsistent server URL
For federated publishing, UploadServiceDefinition typically expects the hosting server admin endpoint or a proper connection. Easiest: publish to PORTAL target instead of direct server URL.
Quick clean fix (most reliable):
Stage locally
Upload using the portal target
Avoid UNC for staging
Minimal change to test:
outdir = r"C:\temp\publish"
arcpy.env.scratchWorkspace = outdir
arcpy.env.workspace = outdir
# Stage locally
arcpy.server.StageService(sddraft_output_filename, sd_output_filename)
# Upload to portal (recommended for hosted/federated)
arcpy.server.UploadServiceDefinition(sd_output_filename, "HOSTING_SERVER")
If that works, the root cause is almost always UNC/temp/permissions. If it still fails, check the StageService messages in arcpy.GetMessages(2) and your Pro install logs.
– Venkat