errors on qload

125 views
Skip to first unread message

Myung-Joong Hwang

unread,
Apr 1, 2013, 10:29:15 PM4/1/13
to qu...@googlegroups.com
hi guys, 

i did mesolve and saved the data using qsave a month ago.
I used to open them without a problem, but now i am running into a following error. could you have a look?
I have qutip version 2.2.0 running on ubuntu 12.04.

thanks,

myung-joong

In [25]: qload('twocavity_NonRWA_0J01_1g0')
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/home/mj/Desktop/TwoCoupledCavities/0J01_data2/<ipython-input-25-cb661a1c77ef> in <module>()
----> 1 qload('twocavity_NonRWA_0J01_1g0')

/usr/lib/python2.7/dist-packages/qutip/fileio.pyc in qload(name)
    261     """
    262     fileObject = open(name + '.qu', 'r')  # open the file for reading
--> 263     out = pickle.load(fileObject)  # return the object from the file
    264     if isinstance(out, Qobj):  # for quantum objects
    265         print('Loaded Qobj object:')

/usr/lib/python2.7/pickle.pyc in load(file)
   1376 
   1377 def load(file):
-> 1378     return Unpickler(file).load()
   1379 
   1380 def loads(str):

/usr/lib/python2.7/pickle.pyc in load(self)
    856             while 1:
    857                 key = read(1)
--> 858                 dispatch[key](self)
    859         except _Stop, stopinst:
    860             return stopinst.value

/usr/lib/python2.7/pickle.pyc in load_inst(self)
   1067         module = self.readline()[:-1]
   1068         name = self.readline()[:-1]
-> 1069         klass = self.find_class(module, name)
   1070         self._instantiate(klass, self.marker())
   1071     dispatch[INST] = load_inst

/usr/lib/python2.7/pickle.pyc in find_class(self, module, name)
   1122     def find_class(self, module, name):
   1123         # Subclasses may override this

-> 1124         __import__(module)
   1125         mod = sys.modules[module]
   1126         klass = getattr(mod, name)

ImportError: No module named Odedata





jrjoh...@gmail.com

unread,
Apr 1, 2013, 11:15:17 PM4/1/13
to qutip group
Hi Myung-Joong

This is a problem with version incomptibility between qutip 2.1.0 and 2.2.0.. Probably you saved the data using qutip 2.1.0 (or earlier) in which the class Odedata was defined in the module qutip.Odedata, but in 2.2.0 the class Odedata defined in the module qutip,odedata. That is, the module qutip.Odedata is renamed to qutip.odedata (for pep8 compliance), and unfortunately this prevents python from loading the old qutip.Odedata module when loading a pickle (which we do in qload).

The easiest way around this problem for now is probably to copy the odedata.py to Odedata,py (just copy, dont remove the original odedata.py) in the qutip installation directory. So in your case, do something like

cd /usr/lib/python2.7/dist-packages/qutip/
sudo cp odedata.py Odedata.py

You might also want to do the save with qobj.py to Qobj.py if you have stored Qobj instances using qsave.

Then next time you try to load the data with qobj it should hopefully work.

Rob

Myung-Joong Hwang

unread,
Apr 2, 2013, 12:40:01 AM4/2/13
to qu...@googlegroups.com
Thanks a lot, Robert! It works like a charm! cheers, Myung-Joong
Reply all
Reply to author
Forward
0 new messages