Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cPickle works in standard interpreter, but not in IPython #29
Original Launchpad bug 363115: https://bugs.launchpad.net/ipython/+bug/363115
For example in IPython:
However, using the standard Python interpreter:
[ LP comment 1 by: avdd, on 2009-07-16 03:48:57.797382+00:00 ]
Has nothing to do with pickle, but the FakeModule that is registered as main:
In : import sys
In : sys.modules[name].foo = 1
In : foo
NameError Traceback (most recent call last)
/home/avdd/ in ()
NameError: name 'foo' is not defined
[ LP comment 2 by: Matt Hickford, on 2009-07-18 19:36:43.821085+00:00 ]
I have problem that neither pickle nor cPickle work in ipython (but work in python proper).
In my case pickle.dump works but pickle.
This is Jaunty, Python 2.6
(I have a custom class inherited from list called Dictionary)
[ LP comment 3 by: Ville M. Vainio, on 2009-07-18 20:11:20+00:00 ]
On Sat, Jul 18, 2009 at 10:36 PM, Matt
I think you'll note that pickle works when the class of the pickleable
Ville M. Vainio
[ LP comment 4 by: reckoner, on 2009-07-19 23:50:39+00:00 ]
If you get the class using the %run magic instead of importing, you DO
Any guidance appreciated.
On Sat, Jul 18, 2009 at 1:11 PM, Ville M. Vainiovivainio@gmail.com wrote:
[ LP comment 5 by: eteq, on 2009-12-17 01:34:20.367155+00:00 ]
I've encountered this in the past - I always just define any class I want to pickle in a file and then reload the module as necessary instead of pickling outputs from run or interactively-defined objects. That seems safer anyway - otherwise if you restart the interpreter, the methods on the object are forgotten.
It seems to work fine if you pickle from a file and then load that file with an interactively-defined or defined in "run" version, though.
The problem appears to be that the FakeModule used for
In : from IPython.core.fakemodule import init_fakemod_dict In : ip = get_ipython() In : fakemain = sys.modules['__main__'] In : ip.register_post_execute(lambda : init_fakemod_dict(fakemain, ip.user_ns))
This manually syncs the
Thanks for the hack, Min. This is a really important one to fix, though I'm reluctant to make it a blocker because it's hard work that may delay us for a while, and it's such an old bug that we've obviously managed to live with it.
But I'd be thrilled to see a proper fix for this.
On Fri, Apr 8, 2011 at 9:49 AM, minrk
My concern would be the fact that this would couple a module (a global
The FakeModule thing is something I wrote years ago, at the very
On Fri, Apr 8, 2011 at 10:46 AM, minrk
That's why I'm reluctant to make this one a blocker right now: it's
On Sat, Apr 9, 2011 at 1:31 PM, dwf
Done, thanks! Unfortunately github only allows repo owners to set labels...