如何解决不支持的pickle协议:4在python 3.5中?

时间:2017-11-30 11:27:39

标签: python protocols python-3.5 pickle

我的代码:

from gensim.models import Word2Vec
from gensim.models import KeyedVectors
import pickle

with open('word2vec_model', 'rb') as handle:
    model = pickle.load(handle)

发生错误:

ValueError
Traceback (most recent call last)
<ipython-input-2-aa1ad84b16ed> in <module>()
         18 #if you do NOT have RAM >= 12GB, use the code below.
         19 with open('word2vec_model', 'rb') as handle:
    ---> 20     model = pickle.load(handle)
C:\Users\home pc\Anaconda2\lib\pickle.pyc in load(file)
       1382 
       1383 def load(file):
    -> 1384     return Unpickler(file).load()
       1385 
       1386 def loads(str):
C:\Users\home pc\Anaconda2\lib\pickle.pyc in load(self)
        862             while 1:
        863                 key = read(1)
    --> 864                 dispatch[key](self)
        865         except _Stop, stopinst:
        866             return stopinst.value
C:\Users\home pc\Anaconda2\lib\pickle.pyc in load_proto(self)
        890         proto = ord(self.read(1))
        891         if not 0 <= proto <= 2:
    --> 892             raise ValueError, "unsupported pickle protocol: %d" % proto
        893     dispatch[PROTO] = load_proto
        894 
ValueError: unsupported pickle protocol: 4

0 个答案:

没有答案