I have a code that a developer created that no long works for me. With a recent upgrade from 2.8.x to 2.9, the script no errors out at a line " project_service_aprx_object.save()". What I believe the code is trying to do update the source of feature layers in a map ("1_Service_Status_On"). However, when it comes to the project_service_aprx_object.save() line, it gives me the following error:
Traceback (most recent call last):
File "<string>", line 686, in <module>
File "A:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 285, in save
return convertArcObjectToPythonObject(self._arc_object.save(*gp_fixargs((), True)))
OSError: G:\SDE_User_Connections\Projects\UnitedStates\US_Test01\Web_Services\Test01_Project_Services.aprx
I'm running the code in an empty APRX file so I don't even have the Test01_Project_Services.aprx open. I'm a novice at python so any I can provide more of the code if necessary.
Solved! Go to Solution.
seems like there are still issues with aprx.save() even in 3.1, I can run a geoprocessing script with modifies then saves an .aprx file once after opening ArcGIS Pro, but the same script a second time will give the OSError until I re-open Pro
project folder/files access permissions?
I would try to do manually in Pro what they code is trying to do, you might get more descriptive error message.
Ihab thanks for responding, my user has admin rights to all the project folders. Also I'm not sure why it's still referencing the default python library. In Pro, I cloned the default python library and use it as the default library, which is saved on the C: drive. One other note is that the code was written in python 2.7.16. Not sure if that makes a difference. These are the lines to the line 686 error:
for project_service_map_object in project_service_map_list:
if project_service_map_object.name == r"1_Service_Status_On":
print("Captured -- " + project_service_map_object.name)
print("Creating a List of Layers in " + project_service_map_object.name)
project_service_layers_list = project_service_map_object.listLayers("*")
print("Updating Data Source for All Layers in the 1_Service_Status_On Map")
for layer in project_service_layers_list:
if not (layer.isGroupLayer or layer.isBasemapLayer):
print("Before: " + str(layer.name))
pprint.pprint(layer.connectionProperties)
layer.updateConnectionProperties(
current_connection_info=project_energizer_sde_workspace,
new_connection_info=p_userconnection_workspace_full_path,
auto_update_joins_and_relates=True,
validate=True,
ignore_case=True)
project_service_aprx_object.save()
Hello!
I'm into this too. We are running and uploading analysis from the past year every single day. Today decided to upgrade ArcGIS PRO to 2.9 version, and now i'm getting this error in all my scripts, every time when i run "aprx.save()". There is a way to downgrade to 2.8 version, i need this stuff working has it was in the past year.
Thanks
Hello,
I'm having the same problem and it has nothing to do with access permissions or anything else. I run the same python in two computers that deal with the same files in our internal network. The one with the Pro 2.7 works and the one with the Pro 2.9 doesn't.
Besides, you don't need much code to show the problem. Two lines are enough to make the python crash:
My Current work around is to use
aprx.saveACopy()
I will second this workaround! I had a similar issue where aprx.save() threw an OSerror, which began after we upgraded from ArcPro 2.8.3 to 2.9.1. We also had the same error on thrown on a GP service after upgrade from arcgis enterprise 10.8.1 to 10.9.1. altering the code to aprx.saveACopy() resulted in normal functionality on both pro and enterprise/server. Thanks for the tip!
I am experiencing this same issue.
I try to save an aprx after loading some layouts using:
aprx.save()
and then I get the error.
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 285, in save
return convertArcObjectToPythonObject(self._arc_object.save(*gp_fixargs((), True)))
ESRI please advise. Are we doing something wrong?
Yep. aprx.save() throws an OSError for me, every single time. v. 2.9
Looks like this is still an issue in Pro 2.9.2
I also get an OSError when calling aprx.save() in my script to replace project data sources
Any word from Esri about this?