AWS:FileNotFoundError:[Errno 2]没有这样的文件或目录

2024-01-03

我正在尝试从我的 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] is

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.8323329.1000.1517875165.878025/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 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')
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

AWS:FileNotFoundError:[Errno 2]没有这样的文件或目录 的相关文章

随机推荐