cPickle.UnpicklingError: invalid load key

2019-05-02 10:13发布

问题:

My program work fine on windows, with cpickle, and I am using binary mode, like 'wb', or 'rb'. When I ran my program on Linux, it still works fine.

But when I tried to unpickle the files obtained from the Linux platform on my windows platform, I got this wired message says: cPickle.UnpicklingError: invalid load key' '.

Can anyone please tell me why?

It seems that I could not unpickle anyfile from the Linux platform.

BTW, the two programs that I run are identical.

Thanks a million.

回答1:

Looking at the code (http://svn.python.org/view/python/trunk/Modules/cPickle.c?revision=81029&view=markup), it looks like it was a parsing error (load key is a pickle format key). It sounds like the file has been altered.

How were the files transferred from Linux to Windows? If it was FTP, did you transfer in binary mode?

(You are using HIGHEST_PROTOCOL right?)



标签: python pickle