Simplicity
Simplicity

Reputation: 48916

_pickle.UnpicklingError: invalid load key, 'x'

I have this pickle file, which I'm trying to unpickle using the following Python script:

import _pickle as pickle

pickle_file = open('bof.pkl', 'rb')
data = pickle.load(pickle_file)

When I run the program, I get the following error:

Traceback (most recent call last):
  File "unpickle.py", line 4, in <module>
    data = pickle.load(pickle_file)
_pickle.UnpicklingError: invalid load key, 'x'.

How can I solve this issue, as I couldn't find a way to do that.

Upvotes: 8

Views: 17710

Answers (1)

Simplicity
Simplicity

Reputation: 48916

I found that the program was using from sklearn.externals import joblib, and thus saved the pickle file as follows:

joblib.dump(....)

I was thus able to load the pickle content as follows:

clf = joblib.load('pickle_file.pkl')

Upvotes: 12

Related Questions