Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DownloadAttachments.py, It does not seem to like itemObject.layers #353

Open
ChrisK9999 opened this issue Apr 29, 2020 · 1 comment
Open

Comments

@ChrisK9999
Copy link

Line 83 DownloadAttachments.py, It does not seem to like itemObject.layers. I am using Arcgis 1.7.0 and Python 3.6.9. Do you any suggestion to how to go about fixing this without going into the arcgis module.

Line 83: for i in range(len(itemObject.layers)):

File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis_init_.py", line 6978, in getattribute
if self['layers'] == None or self['layers'] == []:
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis_init_.py", line 7009, in getitem
return dict.getitem(self, k)
KeyError: 'layers'

@raykendo
Copy link

Looks like if the feature layer was removed, the feature layer id either returns a NoneType, or a poorly constructed object.

  1. First off, make sure the feature layer for the feature layer id actually exists.
  2. If the hosted feature layer is not made publicly accessible, fill in the user name and password
  3. Make sure your org portal URL is correct, too
#What is the ID of the Feature Layer you want to download attachments from?
FeatureLayerId = '092d075f4b3a40f78cf1329b20b0d5e7' # this one no longer exists in ArcGIS Online

#What are your ArcGIS Enterprise/ArcGIS Online credentials? This is case sensitive.
PortalUserName = '' # fill these in if Feature Layer ID above is not publicly accessible
PortalPassword = '' # fill these in if Feature Layer ID above is not publicly accessible
PortalUrl = 'https://www.arcgis.com' # fill this in with your org's URL

If that doesn't work, I'd suggest updating your arcgis library. I'm guessing you're using Windows, by the error message.

In command line (cmd.exe), possibly running as administrator:

C:> C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe -m pip install arcgis --upgrade

I ran the script using arcgis v. 1.8.1 and Python 3.6.9, and received the following error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-358ef73542ab> in <module>
     75 
     76 itemObject = gis.content.get(FeatureLayerId)
---> 77 logger.info('Iterating through layers in Feature Layer "{}"'.format(itemObject.name))
     78 display(itemObject)
     79 

AttributeError: 'NoneType' object has no attribute 'name'

This led me to believe it's an item id that's no longer available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants