cPickle ImportError: No module named multiarray

Posted by Rafal on Stack Overflow See other posts from Stack Overflow or by Rafal
Published on 2010-06-09T10:04:15Z Indexed on 2010/06/09 10:32 UTC
Read the original article Hit count: 686

Filed under:
|
|
|

Hello,

I'm using cPickle to save my Database into file. The code looks like that:

def Save_DataBase():
import cPickle
from scipy import *
from numpy import *
a=Results.VersionName
#filename='D:/results/'+a[a.find('/')+1:-a.find('/')-2]+Results.AssType[:3]+str(random.randint(0,100))+Results.Distribution+".lft"
filename='D:/results/pppp.lft'
plik=open(filename,'w')


DataOutput=[[[DataBase.Arrays.Nodes,DataBase.Arrays.Links,DataBase.Arrays.Turns,DataBase.Arrays.Connectors,DataBase.Arrays.Zones],
             [DataBase.Nodes.Data,DataBase.Links.Data,DataBase.Turns.Data,DataBase.OrigConnectors.Data,DataBase.DestConnectors.Data,DataBase.Zones.Data],
             [DataBase.Nodes.DictionaryPy2Vis,DataBase.Links.DictionaryPy2Vis,DataBase.Turns.DictionaryPy2Vis,DataBase.OrigConnectors.DictionaryPy2Vis,DataBase.DestConnectors.DictionaryPy2Vis,DataBase.Zones.DictionaryPy2Vis],
             [DataBase.Nodes.DictionaryVis2Py,DataBase.Links.DictionaryVis2Py,DataBase.Turns.DictionaryVis2Py,DataBase.OrigConnectors.DictionaryVis2Py,DataBase.DestConnectors.DictionaryVis2Py,DataBase.Zones.DictionaryVis2Py],
             [DataBase.Paths.List]],[Results.VersionName,Results.noZones,Results.noNodes,Results.noLinks,Results.noTurns,Results.noTrips,
                                     Results.Times.VersionLoad,Results.Times.GetData,Results.Times.GetCoords,Results.Times.CrossTheTime,Results.Times.Plot_Cylinder,
                                     Results.AssType,Results.AssParam,Results.tStart,Results.tEnd,Results.Distribution,Results.tVector]]



cPickle.dump(DataOutput, plik, protocol=0)
plik.close()`

And it works fine. Most of my Database rows are lists of a lists, vecor-like, or array-like data sets.

But now when I input data, an error occurs:

def Load_DataBase():
    import cPickle 
    from scipy import *
    from numpy import *  
    filename='D:/results/pppp.lft'
    plik= open(filename, 'rb')
    """ first cPickle load approach """
    A= cPickle.load(plik)
    """ fail """
    """ Another approach - data format exact as in Output step above , also fails"""
    [[[DataBase.Arrays.Nodes,DataBase.Arrays.Links,DataBase.Arrays.Turns,DataBase.Arrays.Connectors,DataBase.Arrays.Zones],
                 [DataBase.Nodes.Data,DataBase.Links.Data,DataBase.Turns.Data,DataBase.OrigConnectors.Data,DataBase.DestConnectors.Data,DataBase.Zones.Data],
                 [DataBase.Nodes.DictionaryPy2Vis,DataBase.Links.DictionaryPy2Vis,DataBase.Turns.DictionaryPy2Vis,DataBase.OrigConnectors.DictionaryPy2Vis,DataBase.DestConnectors.DictionaryPy2Vis,DataBase.Zones.DictionaryPy2Vis],
                 [DataBase.Nodes.DictionaryVis2Py,DataBase.Links.DictionaryVis2Py,DataBase.Turns.DictionaryVis2Py,DataBase.OrigConnectors.DictionaryVis2Py,DataBase.DestConnectors.DictionaryVis2Py,DataBase.Zones.DictionaryVis2Py],
                 [DataBase.Paths.List]],[Results.VersionName,Results.noZones,Results.noNodes,Results.noLinks,Results.noTurns,Results.noTrips,
                                         Results.Times.VersionLoad,Results.Times.GetData,Results.Times.GetCoords,Results.Times.CrossTheTime,Results.Times.Plot_Cylinder,
                                         Results.AssType,Results.AssParam,Results.tStart,Results.tEnd,Results.Distribution,Results.tVector]]= cPickle.load(plik)`

Error is (in both cases):

A= cPickle.load(plik) ImportError: No module named multiarray

Any Ideas?

PS.

© Stack Overflow or respective owner

Related posts about python

Related posts about serialization