Hello,
I am trying to use clone_items for ArcGIS API for Python. I am trying to clone a map to another AGOL folder which should copy the map and all dependent items to the specified folder. This works for other maps in my content but it is failing for the specific map I need to copy today. Does anyone know why this would be failing? I get the following error(s).
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1913, in clone
self._add_features(new_layers, relationships, layer_field_mapping, feature_service.properties['spatialReference'])
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1281, in _add_features
object_id_mapping[layer_id] = {layer_features['attributes'][object_id_field] : add_results['objectId'] for i in range(0, len(layer_features))}
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1281, in <dictcomp>
object_id_mapping[layer_id] = {layer_features['attributes'][object_id_field] : add_results['objectId'] for i in range(0, len(layer_features))}
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "r:\GIS_Warehouse\Production\Projects\CVRP\Scripts\promoteAGOL.py", line 107, in <module>
main()
File "r:\GIS_Warehouse\Production\Projects\CVRP\Scripts\promoteAGOL.py", line 92, in main
successItems = ag.content.clone_items(cloneArray, folder=promoteFolder, search_existing_items=False)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\gis\__init__.py", line 4034, in clone_items
return deep_cloner.clone()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 676, in clone
results = executor.submit(self._clone, executor).result()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\_base.py", line 432, in result
return self.__get_result()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\_base.py", line 384, in __get_result
raise self._exception
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 663, in _clone
raise ex
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\concurrent\futures\thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\_impl\common\_clone.py", line 1922, in clone
raise _ItemCreateException("Failed to create {0} {1}: {2}".format(original_item['type'], original_item['title'], str(ex)), new_item)
arcgis._impl.common._clone._ItemCreateException: ('Failed to create Feature Service xxx: list index out of range', <Item title:"xxx" type:Feature Layer Collection owner:xxx>)
are you using python 3.7 32bit?
Yes, I'm using Python 3.7.1 32 bit.
Install and set up | ArcGIS for Developers
you should be using the version of python that comes with the install. Minimum python 3.5 BUT if you are using the anaconda distribution associated with ArcGIS Pro, that is python 3.6.* 64 bit. I am not sure whether bumping version to 3.7 but bitness down is appropriate.
I'm not sure I understand. I just used pip install arcgis in order to get the API. Is this not the correct way to install?
clone_items does work for me to clone different web maps, it just does not work for this one particular web map. In fact my guess is that there is one particular feature layer that seems to cause issues as it references this feature layer when giving the error 'list index out of range'.
https://anaconda.org/esri/arcgis
conda install -c esri arcgis
Thanks for your help so far. I tried installing anaconda (tried both 32 bit and 64 bit) and installing the arcgis api as you suggested from the anaconda prompt. I then ran my script using the anaconda prompt but the line where I attempt to clone_items still gives me the same error. Interestingly it references a different feature layer now but still gives me the 'list index out of range error'. I should note that I do not currently have ArcGIS Pro installed.
Oh.. that might explain it. If/when you install ArcGIS Pro, you might have a whole world of other issues because of multiple instances of python installations. One anaconda installation provided by pro will allow you to create different environments if needed. It will also allow you to work with arcpy and not rely on other packages to work with geometries.
I suspect someone else might want to weigh in if they have a solution to fix this situation. My suggestion would be to uninstall everything, and install Pro so you have a pristine environment that you can manage (I don't even install arcmap)
Hi Alan,
Let's take a step back and tell me if I'm correct:
Using pip is fine, but it would probably be better to let anaconda handle package management. In any case, if you're not making use of arcpy then using a standalone installation usually simplifies matters.
A few questions:
Hi Earl,
Yes, I'm using a standalone installation. (No Pro). I was not using anaconda until yesterday when Dan suggested this, I was just using Python 3.7.1 and ensured I had the latest version of the API as I used "pip install arcgis upgrade" when I was first having issues.
I am just cloning from one folder in ArcGIS Online (not Portal) to another, all within "My Content".
Almost all of the services in the web map are ArcGIS Online Feature Layers. The only one that is different is I am pulling Stamen Base Map tiles using "Add Layers from Web".
I'll just mention again that my script has worked doing this same task many times in the past. I even tried the same thing on a different map yesterday and it worked no problem. It is just this one map (or perhaps one of the features layers within it) that is giving the script trouble.
Thanks,
Alan