Select to view content in your preferred language

PermissionError when using Jupyter Notebooks

1251
7
09-27-2023 05:34 PM
Labels (1)
JeanineFinn
New Contributor III

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!

 

0 Kudos
7 Replies
RhettZufelt
MVP Notable Contributor

what does

print(data_path)

return?

R_

0 Kudos
JeanineFinn
New Contributor III

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?

 

0 Kudos
RhettZufelt
MVP Notable Contributor

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_

0 Kudos
JeanineFinn
New Contributor III
That worked -- thanks! 
But it's still not liking the string ZIP filename. Very weird.
 

 

# 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'
------------------------------------------------------------
0 Kudos
RhettZufelt
MVP Notable Contributor

.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_

 

0 Kudos
JeanineFinn
New Contributor III

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!

 

0 Kudos
RhettZufelt
MVP Notable Contributor

Yes, os.sep is concatenating the strings together using the Operating System separator to build the path.

R_

0 Kudos