Open Python 2 Pickle in Python 3
Opening a pickle from Python 2 in Python 3 will probably result either:
TypeError: 'str' does not support the buffer interface
or
UnicodeDecodeError: 'ascii' codec can't decode byte 0xab in position 0: ordinal not in range(128)
to solve that you can just use the following code setting the defualt encoding:
import pickle import gzip import numpy as np
with open('var/python2pickle.pkl', 'rb') as f: data = pickle.load(f, encoding='latin1') print(data)