cPickle ImportError:没有名为 multiarray 的模块

发布于 2024-09-04 20:52:03 字数 15398 浏览 7 评论 0原文

我正在使用 cPickle 将数据库保存到文件中。代码看起来像这样:

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()`

它工作正常。我的大多数数据库行都是列表、类似矢量或类似数组的数据集的列表。

但是现在当我输入数据时,会发生错误:

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)`

错误是(在两种情况下):

    Traceback (most recent call last):
  File "D:\programy\projekt_eclipse\src\Praca\wx_frame.py", line 342, in LoadDatabase_Handler
    Load_DataBase()
  File "D:\programy\projekt_eclipse\src\Praca\wx_frame.py", line 1804, in Load_DataBase
    A= cPickle.load(plik)
ImportError: No module named multiarray

有什么想法吗?

附言。现在我已经部分解决了问题:/我需要更改数组的格式。我试图追踪错误,但我做不到。导致错误的变量是这个 (long :) ) :

[[  0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
    0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00]
 [  1.00000000e+00   0.00000000e+00   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  2.00000000e+00   0.00000000e+00   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.52875186e+04]
 [  3.00000000e+00   0.00000000e+00   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  4.00000000e+00   0.00000000e+00   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  5.00000000e+00   0.00000000e+00   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  6.00000000e+00   0.00000000e+00   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  7.00000000e+00   0.00000000e+00   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  8.00000000e+00   0.00000000e+00   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.59846476e+04]
 [  9.00000000e+00   0.00000000e+00   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  1.00000000e+01   1.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.97583022e+04]
 [  1.10000000e+01   1.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.84929461e+04]
 [  1.20000000e+01   1.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.76891311e+03]
 [  1.30000000e+01   1.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   5.10636164e+03]
 [  1.40000000e+01   1.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.45841100e+03]
 [  1.50000000e+01   1.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.22093915e+03]
 [  1.60000000e+01   1.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.20282091e+03]
 [  1.70000000e+01   1.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.86566159e+04]
 [  1.80000000e+01   1.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.80902598e+04]
 [  1.90000000e+01   2.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.23193676e+04]
 [  2.00000000e+01   2.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.16000116e+04]
 [  2.10000000e+01   2.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.05680012e+03]
 [  2.20000000e+01   2.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.89123867e+03]
 [  2.30000000e+01   2.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.98898168e+03]
 [  2.40000000e+01   2.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   7.44216130e+03]
 [  2.50000000e+01   2.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.23593332e+04]
 [  2.60000000e+01   2.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.14424233e+04]
 [  2.70000000e+01   2.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.91864355e+04]
 [  2.80000000e+01   3.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  2.90000000e+01   3.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.61849685e+03]
 [  3.00000000e+01   3.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.09785208e+04]
 [  3.10000000e+01   3.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.99736773e+03]
 [  3.20000000e+01   3.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.06209122e+03]
 [  3.30000000e+01   3.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.48702707e+03]
 [  3.40000000e+01   3.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.04653099e+04]
 [  3.50000000e+01   3.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.25314801e+03]
 [  3.60000000e+01   3.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  3.70000000e+01   4.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  3.80000000e+01   4.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.82241178e+03]
 [  3.90000000e+01   4.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.05149043e+03]
 [  4.00000000e+01   4.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.55692239e+03]
 [  4.10000000e+01   4.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.19199226e+04]
 [  4.20000000e+01   4.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.43876335e+03]
 [  4.30000000e+01   4.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.90454231e+03]
 [  4.40000000e+01   4.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.03525083e+03]
 [  4.50000000e+01   4.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  4.60000000e+01   5.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  4.70000000e+01   5.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.07842319e+03]
 [  4.80000000e+01   5.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.48191278e+03]
 [  4.90000000e+01   5.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.06547361e+04]
 [  5.00000000e+01   5.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.27500595e+04]
 [  5.10000000e+01   5.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.62319628e+03]
 [  5.20000000e+01   5.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.50364667e+03]
 [  5.30000000e+01   5.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.48651846e+03]
 [  5.40000000e+01   5.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  5.50000000e+01   6.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.16862400e+04]
 [  5.60000000e+01   6.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.88311307e+03]
 [  5.70000000e+01   6.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   7.89923519e+03]
 [  5.80000000e+01   6.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.16959736e+03]
 [  5.90000000e+01   6.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.49942081e+03]
 [  6.00000000e+01   6.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.24620368e+03]
 [  6.10000000e+01   6.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.27811830e+03]
 [  6.20000000e+01   6.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.13336356e+04]
 [  6.30000000e+01   6.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.91853045e+04]
 [  6.40000000e+01   7.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.67326624e+04]
 [  6.50000000e+01   7.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.79192625e+04]
 [  6.60000000e+01   7.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.35835049e+03]
 [  6.70000000e+01   7.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.66349011e+03]
 [  6.80000000e+01   7.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.88664273e+03]
 [  6.90000000e+01   7.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.15546726e+03]
 [  7.00000000e+01   7.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.26420582e+03]
 [  7.10000000e+01   7.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.80179725e+04]
 [  7.20000000e+01   7.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.69846102e+04]
 [  7.30000000e+01   8.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  7.40000000e+01   8.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.66207833e+04]
 [  7.50000000e+01   8.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.60000000e+01   8.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.70000000e+01   8.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.80000000e+01   8.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.90000000e+01   8.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  8.00000000e+01   8.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.70098656e+04]
 [  8.10000000e+01   8.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]]

cPickle 或 pickle 无法加载它。但是当我使用控制台手动执行此操作时,相同的文件结构( [[ ]] 和所有格式完全相同,值也是 e+00 格式)然后它工作正常????????????我勒个去? 无论如何,我已经通过更改数据格式解决了问题:/

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):

    Traceback (most recent call last):
  File "D:\programy\projekt_eclipse\src\Praca\wx_frame.py", line 342, in LoadDatabase_Handler
    Load_DataBase()
  File "D:\programy\projekt_eclipse\src\Praca\wx_frame.py", line 1804, in Load_DataBase
    A= cPickle.load(plik)
ImportError: No module named multiarray

Any Ideas?

PS. Now I've solved the problem, say partially :/ I needed to change the format of arrays. I've tried to trace the error, but I couldn't. The variable causing error is this (long :) ) :

[[  0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00
    0.00000000e+00   0.00000000e+00   0.00000000e+00   0.00000000e+00]
 [  1.00000000e+00   0.00000000e+00   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  2.00000000e+00   0.00000000e+00   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.52875186e+04]
 [  3.00000000e+00   0.00000000e+00   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  4.00000000e+00   0.00000000e+00   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  5.00000000e+00   0.00000000e+00   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  6.00000000e+00   0.00000000e+00   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  7.00000000e+00   0.00000000e+00   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.24880978e+04]
 [  8.00000000e+00   0.00000000e+00   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.59846476e+04]
 [  9.00000000e+00   0.00000000e+00   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  1.00000000e+01   1.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.97583022e+04]
 [  1.10000000e+01   1.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.84929461e+04]
 [  1.20000000e+01   1.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.76891311e+03]
 [  1.30000000e+01   1.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   5.10636164e+03]
 [  1.40000000e+01   1.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.45841100e+03]
 [  1.50000000e+01   1.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.22093915e+03]
 [  1.60000000e+01   1.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.20282091e+03]
 [  1.70000000e+01   1.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.86566159e+04]
 [  1.80000000e+01   1.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.80902598e+04]
 [  1.90000000e+01   2.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.23193676e+04]
 [  2.00000000e+01   2.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.16000116e+04]
 [  2.10000000e+01   2.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.05680012e+03]
 [  2.20000000e+01   2.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.89123867e+03]
 [  2.30000000e+01   2.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.98898168e+03]
 [  2.40000000e+01   2.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   7.44216130e+03]
 [  2.50000000e+01   2.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.23593332e+04]
 [  2.60000000e+01   2.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.14424233e+04]
 [  2.70000000e+01   2.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.91864355e+04]
 [  2.80000000e+01   3.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  2.90000000e+01   3.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.61849685e+03]
 [  3.00000000e+01   3.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.09785208e+04]
 [  3.10000000e+01   3.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.99736773e+03]
 [  3.20000000e+01   3.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.06209122e+03]
 [  3.30000000e+01   3.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.48702707e+03]
 [  3.40000000e+01   3.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.04653099e+04]
 [  3.50000000e+01   3.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.25314801e+03]
 [  3.60000000e+01   3.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  3.70000000e+01   4.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  3.80000000e+01   4.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.82241178e+03]
 [  3.90000000e+01   4.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.05149043e+03]
 [  4.00000000e+01   4.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.55692239e+03]
 [  4.10000000e+01   4.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.19199226e+04]
 [  4.20000000e+01   4.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.43876335e+03]
 [  4.30000000e+01   4.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.90454231e+03]
 [  4.40000000e+01   4.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.03525083e+03]
 [  4.50000000e+01   4.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  4.60000000e+01   5.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.07766798e+04]
 [  4.70000000e+01   5.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.07842319e+03]
 [  4.80000000e+01   5.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.48191278e+03]
 [  4.90000000e+01   5.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.06547361e+04]
 [  5.00000000e+01   5.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.27500595e+04]
 [  5.10000000e+01   5.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.62319628e+03]
 [  5.20000000e+01   5.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.50364667e+03]
 [  5.30000000e+01   5.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.48651846e+03]
 [  5.40000000e+01   5.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.67608539e+04]
 [  5.50000000e+01   6.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.16862400e+04]
 [  5.60000000e+01   6.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.88311307e+03]
 [  5.70000000e+01   6.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   7.89923519e+03]
 [  5.80000000e+01   6.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   8.16959736e+03]
 [  5.90000000e+01   6.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.49942081e+03]
 [  6.00000000e+01   6.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   6.24620368e+03]
 [  6.10000000e+01   6.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.27811830e+03]
 [  6.20000000e+01   6.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.13336356e+04]
 [  6.30000000e+01   6.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.91853045e+04]
 [  6.40000000e+01   7.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.67326624e+04]
 [  6.50000000e+01   7.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.79192625e+04]
 [  6.60000000e+01   7.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.35835049e+03]
 [  6.70000000e+01   7.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.66349011e+03]
 [  6.80000000e+01   7.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.88664273e+03]
 [  6.90000000e+01   7.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   4.15546726e+03]
 [  7.00000000e+01   7.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   9.26420582e+03]
 [  7.10000000e+01   7.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   1.80179725e+04]
 [  7.20000000e+01   7.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.69846102e+04]
 [  7.30000000e+01   8.00000000e+03   0.00000000e+00   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]
 [  7.40000000e+01   8.00000000e+03   1.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.66207833e+04]
 [  7.50000000e+01   8.00000000e+03   2.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.60000000e+01   8.00000000e+03   3.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.70000000e+01   8.00000000e+03   4.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.80000000e+01   8.00000000e+03   5.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  7.90000000e+01   8.00000000e+03   6.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   2.32529854e+04]
 [  8.00000000e+01   8.00000000e+03   7.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   3.70098656e+04]
 [  8.10000000e+01   8.00000000e+03   8.00000000e+03   2.00000000e+01
    0.00000000e+00   5.00000000e+02   2.00000000e+01   0.00000000e+00]]

cPickle, or pickle are unable to load it. But when I do it manually with the console, the same file structure ( [[ ]] and all formats exaclty the same, values also e+00 format) Then it works fine ??????????? What the hell?
Anyway I've solved the problem by changign data format :/

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

情绪失控 2024-09-11 20:52:03

我在 Windows XP 机器上遇到了同样的问题,代码在 Linux 下运行良好。这可能与文本和二进制文件的不同处理有关。当写入数据时,尝试创建文件对象,明确说明您想要二进制模式,即而

plik=open(filename,'wb')

不是

plik=open(filename,'w')

对我有用。

I had the same problem on a Windows XP machine with Code that worked fine under Linux. It may have to do with the different handling of text and binary files. When writing your data try to create the file object explicitly stating that you want binary mode, i.e.

plik=open(filename,'wb')

instead of

plik=open(filename,'w')

That worked for me.

我要还你自由 2024-09-11 20:52:03

首先检查 $YOUR_PYTHON_INSTALLATION/lib/python-xx/site-packages/numpy/core/multiarray.so 文件是否存在。

如果您发布完整的回溯,而不仅仅是错误消息,这将非常有用。

First of all check if $YOUR_PYTHON_INSTALLATION/lib/python-x.x/site-packages/numpy/core/multiarray.so file exists.

And it would be very useful if you posted full traceback, not only the error message.

烟酉 2024-09-11 20:52:03

您是否尝试过显式导入多数组? pickle 需要定义所有类才能导入数据。

Have you tried importing multiarray explicitly? pickle needs all the classes to be defined in order to import the data.

沫尐诺 2024-09-11 20:52:03

这可能是由于 git 使用 autocrlf 在 Windows 计算机上更改行结尾造成的。您会注意到,除非您更改分支或执行任何其他删除和重写磁盘上文件的操作,否则这不会成为问题。
将此行添加到您的 .gitattributes 文件中,以避免重写类似文本(但实际上是二进制!)pickle 文件中的行结尾:

# .gitattributes
# Pickle files are to be treated as binary. 
*.p binary
*.lft binary

This can be caused by git changing line endings on a Windows machine with autocrlf. You'll notice that it won't be a problem until you change branches or do anything else that deletes and rewrites the file on disk.
Add this line to your .gitattributes file to avoid rewriting line endings in the text-like (but actually binary!) pickle files:

# .gitattributes
# Pickle files are to be treated as binary. 
*.p binary
*.lft binary
偏爱你一生 2024-09-11 20:52:03

您使用的一定是非常古老的 Python。因为“import *”仅在模块级别可用。不管怎样,回答你的问题:

将这些语句

import cPickle 
from scipy import *
from numpy import *

移出 Load_DataBase 定义,就可以了。引发异常是因为 cPickle 找不到 plik 内容的元信息。

You must be using a very old Python. Because 'import *' is only available at module level. Anyway, to answer your question:

Move these statements

import cPickle 
from scipy import *
from numpy import *

out of the Load_DataBase definition and you'll be fine. The exception was raised because cPickle can't find the meta information for the content of plik.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文