Python 2.7 pickle won't recognize numpy multiarray

I need to download a salt data set from a collaborator. The problem is that for this I need multiple. My code is as follows:

f = open('data.p', 'rb')
a = pickle.load(f)

And here is the error message.

ImportError                               Traceback (most recent call last)
<ipython-input-3-17918c47ae2d> in <module>()
----> 1 a = pk.load(f)

/usr/lib/python2.7/pickle.pyc in load(file)
   1382 
   1383 def load(file):
-> 1384     return Unpickler(file).load()
   1385 
   1386 def loads(str):

/usr/lib/python2.7/pickle.pyc in load(self)
    862             while 1:
    863                 key = read(1)
--> 864                 dispatch[key](self)
    865         except _Stop, stopinst:
    866             return stopinst.value

/usr/lib/python2.7/pickle.pyc in load_global(self)
   1094         module = self.readline()[:-1]
   1095         name = self.readline()[:-1]
-> 1096         klass = self.find_class(module, name)
   1097         self.append(klass)
   1098     dispatch[GLOBAL] = load_global

/usr/lib/python2.7/pickle.pyc in find_class(self, module, name)
   1128     def find_class(self, module, name):
   1129         # Subclasses may override this
-> 1130         __import__(module)
   1131         mod = sys.modules[module]
   1132         klass = getattr(mod, name)

ImportError: No module named multiarray

I thought this was a compiled numpy problem on my computer. So I removed numpy from my Arch Linux replication and installed numpy via

sudo -H pip2 install numpy

However, the problem persists. I checked the folder $PACKAGE-SITE/numpy/core, multiarray.soin it. And I have no idea why the pickle cannot load the module.

How can i solve the problem? What else do I need to do?

PS1. Arch Linux. python 2.7 . . PS2. . , python, .

+4
1

@MikeMcKems .

, MS Windows Linux (, ). Windows

pickle.dump(obj, 'filename', 'w')

. Linux-, , .

- Windows,

a=pickle.load(open('filename_in', 'r'))

pickle.dump(a, open('filename_out', 'wb'))

, pickle , filename_out Python Linux.

+8

Source: https://habr.com/ru/post/1628471/


All Articles