Hello --
I am working my way through these ArcGIS API for Python tutorials and hit a snag on this one: https://developers.arcgis.com/python/guide/download-data/
At Step 4, creating a directory for the data and downloading the zip file, I get a permission error.
PermissionError Traceback (most recent call last) In [11]: Line 4: data_path.mkdir() File C:\Users\JeanineF\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\pathlib.py, in mkdir: Line 1323: self._accessor.mkdir(self, mode) PermissionError: [WinError 5] Access is denied: 'data'
I've looked around in these directories with a terminal window and I have correct permissions as far as I can tell (I've confirmed with our IT as well).
Is there some conflict here I'm not understanding?
Thanks!
what does
print(data_path)
return?
R_
It just returns
data
Which is not correct? That line of code creating the data_path variable looks like is should be creating a path to "data" directory within the current directory, yes?
It says "to the notebook server's current location". So, may or may not exist or have permissions depending on where it is.
You might try creating a local folder (eg. C:\data) and hardcode the path to that folder.
data_path = r'C:\data'
You will have to update it in steps 4-6.
This will at least tell us if it is a location/permission issue.
R_
# configure where to save the data, and where the ZIP file is located
data_path = r'C:\gis'
###if not data_path.exists():
### data_path.mkdir()
zip_path = data_path.joinpath('LA_Hub_Datasets.zip')
extract_path = data_path.joinpath('LA_Hub_datasets')
data_item.download(save_path=data_path)
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) In [9]: Line 5: zip_path = data_path.joinpath('LA_Hub_Datasets.zip') AttributeError: 'str' object has no attribute 'joinpath' ------------------------------------------------------------
.joinpath is specific to the pathlib. with the hard coded path:
zip_path = data_path + os.sep + 'LA_Hub_Datasets.zip'
extract_path = data_path + os.sep + 'LA_Hub_datasets'
should work.
R_
Thanks -- that did it. I had to go back and import the os module for this Notebook but that did it.
"os.sep" tells it how to connect the paths since we're not using ".joinpath" -- correct?
Thanks for your help!
Yes, os.sep is concatenating the strings together using the Operating System separator to build the path.
R_