NEURON 7.2 + Python + cPickle on Fedora 17- hoc module error
Posted: Fri Feb 08, 2013 8:08 pm
Guys,
I'm trying to do something that may seem a little odd - I want to serialize a NEURON cell and write it to disk so that I can move it to another computer (and easily load the cell again).
The cell is implemented using a combination of HOC and Python code, and I'm using the cPickle module to try to dump the cell to disk. When I do so, I get the following error:
where the major error is the following:
PicklingError: Can't pickle <type 'hoc.HocObject'>: import of module hoc failed
I got to this by calling
ipython -i <filename>
If I get to it by calling
nrniv -python <filename>
then I can successfully write the cell to disk. However, when I read it back in again, I get the following ("original" is the original cell, "new" is the cell read in from disk):
So it looks like, in this case as well, though the write-to-disk appeared to occur successfully, it actually didn't, as the hoc object isn't right when it gets read back in...
Any ideas about what's going on here?
I'm trying to do something that may seem a little odd - I want to serialize a NEURON cell and write it to disk so that I can move it to another computer (and easily load the cell again).
The cell is implemented using a combination of HOC and Python code, and I'm using the cPickle module to try to dump the cell to disk. When I do so, I get the following error:
Code: Select all
PicklingError Traceback (most recent call last)
/usr/lib/python2.7/site-packages/IPython/utils/py3compat.pyc in execfile(fname, *where)
173 else:
174 filename = fname
--> 175 __builtin__.execfile(filename, *where)
[removed]/pickleCellClass.py in <module>()
22
23 f = open("cPickle_Test",'w')
---> 24 cPickle.dump(GC,f,protocol=2)
25 f.close()
26
PicklingError: Can't pickle <type 'hoc.HocObject'>: import of module hoc failed
In [1]: hoc
Out[1]: <module 'neuron.hoc' from '/usr/lib64/python2.7/site-packages/neuron/hoc.so'>
In [2]:
PicklingError: Can't pickle <type 'hoc.HocObject'>: import of module hoc failed
I got to this by calling
ipython -i <filename>
If I get to it by calling
nrniv -python <filename>
then I can successfully write the cell to disk. However, when I read it back in again, I get the following ("original" is the original cell, "new" is the cell read in from disk):
Code: Select all
>>> original.c.all
<hoc.HocObject object at 0x1aa8b28>
>>> new.c.all
Traceback (most recent call last):
File "stdin", line 1, in <module>
AttributeError: 'hoc.HocObject' object has no attribute 'all'
Any ideas about what's going on here?