Python pickle error: UnicodeDecodeError
I think you should open the file as
f = open('sample_classifier.pickle', 'rb')
cl = pickle.load(f)
You shouldn't have to decode it. pickle.load
will give you an exact copy of whatever it is you saved. At this point you, should be able to work with cl
as if you just created it.
maybe the file was encoded using latin1:
f = open('sample_classifier.pickle', encoding="latin1")
By choosing to open
the file in mode wb
, you are choosing to write in raw binary. There is no character encoding being applied.
Thus to read this file, you should simply open
in mode rb
.