在terminal输入python后,执行命令报错:
import numpy
import pickle
import numpy.core.multiarray
data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27','rb'))
报错:
Traceback (most recent call last):
File “”, line 1, in
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1384, in load
return Unpickler(file).load()
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 864, in load
dispatchkey
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1096, in load_global
klass = self.find_class(module, name)
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1130, in find_class
import(module)
ImportError: No module named multiarray
data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27','r'))
报错:
Traceback (most recent call last):
File “”, line 1, in
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1384, in load
return Unpickler(file).load()
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 864, in load
dispatchkey
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1096, in load_global
klass = self.find_class(module, name)
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1130, in find_class
import(module)
ImportError: No module named multiarray
data = pickle.load(open('Workspace/Ch5_Py_Mrjob_PegasosSVM/svmDat27'))
继续报错:
Traceback (most recent call last):
File “”, line 1, in
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1384, in load
return Unpickler(file).load()
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 864, in load
dispatchkey
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1096, in load_global
klass = self.find_class(module, name)
File “/home/hduser/anaconda2/lib/python2.7/pickle.py”, line 1130, in find_class
import(module)
ImportError: No module named multiarray
补充解决方案来了
并不是代码本身的编码有问题,是数据存储格式有问题1!!!1解决方法:vim 进入数据文件,:set ff=unix