I am not able to do a simpe pickle load on my VM. Here is simple demo code of that.
root@bn18-6:~# python
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> x = {1:2 }
>>> f = open ('demo', 'wb+')
>>> f
<open file 'demo', mode 'wb+' at 0x7fae71b44660>
>>> pickle.dump(x, f)
>>>
>>>
>>> f.close ()
>>>
>>>
>>> p = open('demo', 'wb+')
>>> p
<open file 'demo', mode 'wb+' at 0x7fae71b446f0>
>>> a = pickle.load (p)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/pickle.py", line 1384, in load
return Unpickler(file).load()
File "/usr/lib/python2.7/pickle.py", line 864, in load
dispatch[key](self)
File "/usr/lib/python2.7/pickle.py", line 886, in load_eof
raise EOFError
EOFError
I have used pickling and unpickling several times before for larger data but didnt encounter this problem.
I have tried with 'r+'
,'w+'
too.
I have found This relevent but the solution involves increasing the RAM which is not possible in my case,
Also there are several questions dealing with pickle errors but most of them had problems with file open mode.