1

I'm running a code written in python 2 (not sure the exact version) using python 3.6. I'm having difficulties unpickling a file in python 3 that was pickled in python 2.

I have tried solutions given in similar questions using joblib.load, but that doesnt work for python 3 either. I have also included the encoding=latin1 but still didnt work.

with open('final_model.pkl', 'rb') as f:
    model = pickle.load(f, encoding='latin1')

print("Loading other information...")

with open('final_tfidf.pkl', 'rb') as f:
    tf_vectorizer = pickle.load(f, encoding='latin1')
with open('final_idf.pkl', 'rb') as f:
    idf_vector = pickle.load(f, encoding='latin1')
with open('final_pos.pkl', 'rb') as f:
    pos_vectorizer = pickle.load(f, encoding='latin1')

the error message is: _pickle.UnpicklingError: invalid load key, '\x00'.

and it points to the first pickle.load statement: model = pickle.load(f, encoding='latin1')

KoKo
  • 349
  • 5
  • 24

0 Answers0