当我尝试将数据上传到S3存储桶时,我遇到了SageMaker的问题。我收到这个错误:
import os import urllib.request import boto3 def download(url): filename = url.split("/")[-1] if not os.path.exists(filename): urllib.request.urlretrieve(url, filename) def upload_to_s3(channel, file): s3 = boto3.resource('s3') data = open(file, "rb") key = channel + '/' + file s3.Bucket(bucket).put_object(Key=key, Body=data) # caltech-256 download('http://data.mxnet.io/data/caltech-256/caltech-256-60-train.rec') upload_to_s3('train', 'caltech-256-60-train.rec')
这是脚本:
<div class="release-bg"></div>
答案 0 :(得分:4)
正如错误所说,变量bucket
未定义。
你可能想要做一些像
bucket = <name of already created bucket in s3>
之前打电话
s3.Bucket(bucket).put_object(Key=key, Body=data)