在python 3中加载hickle文件(来自python2)

时间:2018-07-19 02:48:24

标签: python-2.7 python-3.6

当我尝试加载hickle文件时,这是错误,该怎么办?

hkl.load("sources_test.hkl")

Traceback (most recent call last):
File "", line 1, in File "/opt/conda/envs/pytorch-py3.6/lib/python3.6/site-packages/hickle/hickle.py", line 515, in load raise RuntimeError("Cannot open file. This file was likely" RuntimeError: Cannot open file. This file was likely created with Python 2 and an old hickle version.

1 个答案:

答案 0 :(得分:1)

在Python 2.7中加载hickle文件,使用protocol=0(缓慢但安全)将其与腌菜一起转储。将pickle文件加载到Python 3.6中,然后再次使用hickle进行转储,这样您现在就拥有了与Python 3.6兼容的hickle文件。