python - `PermissionError: [Errno 13] Permission denied: 'C:Users'` on Google Cloud Storage - Stack Overflow

admin2025-04-21  0

SUPER new to Google Cloud

I'm trying to access my data that is stored on the Google cloud storage.

I have Google Cloud SDK open one one screen to log in and VScode in another.

Here are my admin permissions.

This is a test dataset and open source so I don't mind granting all users:

Here the example code from the Google Docs:

from google.cloud import storage


def download_blob(bucket_name, source_blob_name, destination_file_name):
    """Downloads a blob from the bucket."""


    # The ID of your GCS bucket
    # bucket_name = "your-bucket-name"

    # The ID of your GCS object
    # source_blob_name = "storage-object-name"

    # The path to which the file should be downloaded
    # destination_file_name = "local/path/to/file"

    storage_client = storage.Client(project="cse6242team12project")

    bucket = storage_client.bucket(bucket_name)

    # Construct a client side representation of a blob.
    # Note `Bucket.blob` differs from `Bucket.get_blob` as it doesn't retrieve
    # any content from Google Cloud Storage. As we don't need additional data,
    # using `Bucket.blob` is preferred here.
    blob = bucket.blob(source_blob_name)
    blob.download_to_filename(destination_file_name)

    print(
        "Downloaded storage object {} from bucket {} to local file {}.".format(
            source_blob_name, bucket_name, destination_file_name
        )
    )

I've checked my folder permissions and my destination_file_name folder named test is set to "write" when I checked the security permissions under right click-> properties.

What would be the issue? When I called the function download_blob("team12data", "housepricesLA.geojson", "C:/Users") I still get

PermissionError: [Errno 13] Permission denied: 'C:/Users'

SUPER new to Google Cloud

I'm trying to access my data that is stored on the Google cloud storage.

I have Google Cloud SDK open one one screen to log in and VScode in another.

Here are my admin permissions.

This is a test dataset and open source so I don't mind granting all users:

Here the example code from the Google Docs:

from google.cloud import storage


def download_blob(bucket_name, source_blob_name, destination_file_name):
    """Downloads a blob from the bucket."""


    # The ID of your GCS bucket
    # bucket_name = "your-bucket-name"

    # The ID of your GCS object
    # source_blob_name = "storage-object-name"

    # The path to which the file should be downloaded
    # destination_file_name = "local/path/to/file"

    storage_client = storage.Client(project="cse6242team12project")

    bucket = storage_client.bucket(bucket_name)

    # Construct a client side representation of a blob.
    # Note `Bucket.blob` differs from `Bucket.get_blob` as it doesn't retrieve
    # any content from Google Cloud Storage. As we don't need additional data,
    # using `Bucket.blob` is preferred here.
    blob = bucket.blob(source_blob_name)
    blob.download_to_filename(destination_file_name)

    print(
        "Downloaded storage object {} from bucket {} to local file {}.".format(
            source_blob_name, bucket_name, destination_file_name
        )
    )

I've checked my folder permissions and my destination_file_name folder named test is set to "write" when I checked the security permissions under right click-> properties.

What would be the issue? When I called the function download_blob("team12data", "housepricesLA.geojson", "C:/Users") I still get

PermissionError: [Errno 13] Permission denied: 'C:/Users'

Share Improve this question edited Feb 21 at 2:26 Doug Stevenson 319k36 gold badges456 silver badges473 bronze badges Recognized by Google Cloud Collective asked Feb 21 at 0:49 myts999myts999 771 silver badge10 bronze badges 2
  • "your" code looks like sample code from Google. It's just a function, which won't do anything unless it's called by some other code. Where is the code that calls this function, and what parameters are you passing to it? – Tangentially Perpendicular Commented Feb 21 at 1:07
  • Yes I'm using the example code from Google my bad for clarification. download_blob("team12data", "housepricesLA.geojson", "C:/Users") thats exactly what I'm trying to pass – myts999 Commented Feb 21 at 1:23
Add a comment  | 

1 Answer 1

Reset to default 0

destination_file_name should be the path to a file (not a directory) where you want the downloaded file to exist. It looks like you're passing a directory, not a file.

Maybe you'll have better results with something like this:

download_blob("team12data", "housepricesLA.geojson", "C:/Users/some_file_name")
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745171864a288705.html

最新回复(0)