3

I am running some demo code from vehicle-prediction. When comes to the models in models directory, I can load this model model_2000_car_100_iter_v.pkl in Python2, but My integration environment is Python3. So when I run the codes to load the model in Python3 using joblib.load(), errors are raised:

UnicodeDecodeError: 'ascii' codec can't decode byte 0x80 in position 1024: ordinal not in range(128)

and

    raise new_exc
  ValueError: You may be trying to read with python 3 a joblib pickle generated with python 2. This is not feature supported by joblib.

I try to figure this out referring to pickle, because joblib is refered to pickle. so the pickle doc says encoding = 'latin1' can avoid this issue, but without success. And I also try 'iso-8859-1' encoding, which is also failed.

import pickle
picklefile=open('model_2000_car_100_iter_v.pkl','rb')
data=pickle.load(picklefile,encoding='iso-8859-1')  # or 'latin1'

I can see that pickle allows user to save model in Python3, and load it in Python2, using the protocol parameter, but how can I do this in reverse? Is there a way to load the model in different python version using joblib?

Eskapp
  • 3,419
  • 2
  • 22
  • 39
wenyunlong
  • 31
  • 2
  • You tag `hmmlearn` but I see no reference to the hmmlearn library in your question. Is your model an output from hmmlearn? In that case, can you share the code of how you export it to a `.pkl` file? If it is not related, please edit your question removing the tag. – Eskapp May 16 '19 at 15:14

0 Answers0