ImportError in Unpickle

D

draghuram

Hi,

I have a python script that pickles and unpickles a give object. It
works without any problems on windows (the data was pickled on windows
first). But when I try to run the script on Linux, I get the following
error:

mydbinfo = pickle.Unpickler(f).load()
File "/usr/lib/python2.3/pickle.py", line 872, in load
dispatch[key](self)
File "/usr/lib/python2.3/pickle.py", line 1083, in load_inst
klass = self.find_class(module, name)
File "/usr/lib/python2.3/pickle.py", line 1138, in find_class
__import__(module)
ImportError: No module named __main__

Even running the script with cygwin's python results in same error. It
looks me to be some problem with path setting for finding modules. Can
someone shed more light?

Thanks in advance,
Raghu.
 
R

Rene Pijlman

(e-mail address removed):
I have a python script that pickles and unpickles a give object. It
works without any problems on windows (the data was pickled on windows
first). But when I try to run the script on Linux, I get the following
error: [...]
ImportError: No module named __main__

There are some posts in the Usenet archive that suggest you need to open
the pickled file in binary mode.
http://groups.google.nl/group/comp.lang.python/browse_frm/thread/2da0dcfc0a414251/0885a7a5723f3b03
 
D

draghuram

It is indeed the problem. Thanks.

May be, this fact could have been mentioned in the documentation. I
have suggested the change using bug tracker.

Raghu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top