[Tutor] Cannot cPickle.load()

Tim Peters tim.peters at gmail.com
Wed Dec 1 02:54:02 CET 2004

[Hugo González Monteverde <hugonz-lists at h-lab.net>]
> I think I must be missing something here. I pickled a dictionary of
> lists into a file, using protocol 2, some weeks ago.  Now I'm trying to
> load it and I can't.
> File is 21kB long, so I know it has data in it, and when I read it into
> a string (without pickling) I understand the pickle is there. Here's  my
> log:
> IDLE 1.0.3
> >>> import cPickle
> >>> import pickle
> >>> myfilep=open("e:\Devel\listpickled", "r")

and try again.

You're on Windows, pickles are binary files, and binary files must
always be opened in binary mode on Windows.  When you wrote the data
to the file to begin with, I hope you opened the file in binary mode
then too.  Else the data in the file is corrupt now.

More information about the Tutor mailing list