2

a friend generates a pickle file for me. As he works on python 3 while I work on python 2, so he generated the file with

pickle.dump(some_file_to_be_pickled,open("path_to_that_file","wb+"),protocol=2)

While I tried to load it with

the_file = pickle.load(open("path_to_that_file","rb"))

However, I met the EOFError, which looks like:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/pickle.py", line 1378, in load
   return Unpickler(file).load()
File "/usr/lib64/python2.7/pickle.py", line 858, in load
   dispatch[key](self)
File "/usr/lib64/python2.7/pickle.py", line 880, in load_eof
   raise EOFError
EOFError

My friend also tried to load this file on his computer with python 2 and he didn't have any problem doing that...

Any idea to fix this problem? By the way, I am using python 2.7.5 while he is using python 2.7.10 and python 3.5.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
gladys0313
  • 2,569
  • 6
  • 27
  • 51

1 Answers1

0

I believe I had tried a something very similar and received the same result you are having; I was also running 2.7.5. When I updated to 3.4, I didn't receive the error anymore and my function ran properly, so more than likely I would say the problem is your python is outdated.

TheDarkHoarse
  • 416
  • 4
  • 9