提问人:JPV 提问时间:4/16/2023 最后编辑:JPV 更新时间:4/17/2023 访问量:96
使用 Python3.8 的泡菜 EOF
Pickle EOF with Python3.8
问:
我最近刚刚将我的 python 版本从 3.6 更改为 3.8,我正在为我的泡菜文件格式而苦苦挣扎。 我的代码正在将一个对象写入泡菜文件“5lc_payload0.pickle”
with open('5lc_payload0.pickle', 'wb') as f:
pickle.dump(my_object, f)
然后通过简单的上传操作上传到 S3。
def upload_files(self, items: List[Tuple[StorageUrl, PathLike]]):
def upload_item(item):
#(content_type, encoding) = mimetypes.guess_type(item[0].url)
content_type='application/octet-stream'
logger.info(f"Uploading single item {item[0]},{item[1]}, {content_type} ")
self.upload_file(item[0], item[1], content_type)
with futures.ThreadPoolExecutor(max_workers=5) as executor:
submitted = [executor.submit(upload_item, item) for item in items]
for f in futures.as_completed(submitted):
f.result()
从 s3 '5lc_payload0_s3.pickle' 下载文件并尝试使用
aws s3 cp s3://temp-data/777775555/5lc_payload0.pickle 5lc_payload0_s3.pickle
with open('5lc_payload0_s3.pickle', 'rb') as f:
pickle.load(f)
我得到“EOFError:运行输入”
到目前为止,我一直在进行许多软件包版本更改,但没有成功。问题是上面的代码适用于 python3.6,但不适用于 python3.8
我正在使用 pandas 1.4、boto3 1.17.28 和 botocore 1.20.112
答: 暂无答案
评论
ls -l
-h