所以这里:
glove_path = './embeddings/glove_{}_{}.pkl'.format(dataset,mode)
if(os.path.isfile(glove_path)):
print("Reusing glove dictionary to save time")
#with open(glove_path,'r') as f:
with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
glove = pickle.load(f)
save = False
如果我尝试
with open(glove_path,'r') as f:
我得到以下错误:
Reusing glove dictionary to save time
Traceback (most recent call last):
File "prepare.py", line 315, in <module>
glove = pickle.load(f)
TypeError: a bytes-like object is required, not 'str'
如果我试着
with open(glove_path, 'rb') as f: #python 3 for pickle byte size object is needed not str
我得到以下错误:
Reusing glove dictionary to save time
Traceback (most recent call last):
File "prepare.py", line 315, in <module>
glove = pickle.load(f)
EOFError: Ran out of input
你能指导一下如何解决这个问题吗?
我使用的是https://github.com/vanzytay/pytorch_sentiment_rnn和Anaconda Python 3.6
中的代码。
我有像这样的进口泡菜
import six; from six.moves import cPickle as pickle #import compatability with Python 2 using six
虽然它最初被导入为:
import cPickle as pickle #python 2
发布于 2018-03-08 23:02:02
"EOFError: Ran of input“表示您正在尝试读取空文件。检查您尝试读取的文件是否不为空。
https://stackoverflow.com/questions/49183719
复制相似问题