Search code examples
pythonfirebase-storageimagedownload

PermissionError: [errno 13] permission denied when running python script in Windows 10


When I run my python script for downloading an image from Firebase storage I get the following error "PermissionError: [Errno 13] Permission denied:". I have tried running as administrator without success and also checked the permissions and it appears in my settings I have full read and write access so I'm not sure what to do?

This is the code I am running:

import os 
from google.cloud import storage
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'C:/Users/username/Documents/NNFILES/credential_file.json'
storage_client = storage.Client()
bucket = storage_client.get_bucket('project.appspot.com')
imageBlob = bucket.blob("/")
imagePath1 = "C:\\Users\\username\\Downloads"
Blob = bucket.blob('result_5.png')
Blob.download_to_filename(imagePath1)
Blob.download_as_string()

Also to add I am successfully uploading to Firebase storage so I do not think it is an issue with the .json file or Firebase.


Solution

  • imagePath1 = "C:\\Users\\username\\Downloads" is not a filename. You're trying to copy a file over the top of a directory. You need to add the file name to the end of that string.