gpt4 book ai didi

amazon-web-services - AWS : FileNotFoundError: [Errno 2] No such file or directory

转载 作者:行者123 更新时间:2023-12-04 14:19:02 29 4
gpt4 key购买 nike

我正在尝试从我的 S3 存储桶中将文件下载到 sagemaker。

文件的路径是s3://vemyone/input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.8323329.1000.1517875165.878025/1.2.276.0.7230010.3.1.4.8323329.1000 .1517875165.878027.dcm

该文件的路径作为列表元素存储在 train_fns[0] 中。

train_fns[0] 的值为

input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.8323329.1000.1517875165.878025/1.2.276.0.7230010.3.1.4.8323329.1000.1517875165.878027. dcm

我使用了以下代码:

s3 = boto3.resource('s3')
bucketname = 'vemyone'

s3.Bucket(bucketname).download_file(train_fns[0][:], train_fns[0])

但我收到以下错误:

FileNotFoundError: [Errno 2] No such file or directory: 'input/dicom-images-train/1.2.276.0.7230010.3.1.2.8323329.1000.1517875165.878026/1.2.276.0.7230010.3.1.3.83237.185258.1.3.83237.29.150580/1.2.276.0.7230010.3.1.4.8323329.1000.1517875165.878027.dcm.5b003ba1'

我注意到一些字符已附加到路径的末尾。

我该如何解决这个问题?

最佳答案

请参阅https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html#S3.Bucket.download_file

根据文档,第一个参数是文件键,第二个参数是本地文件的路径:

s3 = boto3.resource('s3')
bucketname = 'vemyone'

s3.Bucket(bucketname).download_file(train_fns[0], '/path/to/local/file')

关于amazon-web-services - AWS : FileNotFoundError: [Errno 2] No such file or directory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56969859/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com