AttributeError:模块“ pickle”没有属性“ _Pickler”

时间:2018-12-16 04:03:59

标签: python heroku flask pickle

我试图通过Heroku打开Flask应用,但出现此错误:

  

AttributeError :模块'pickle'没有属性_' Pickler'

我在一个单独的文件中创建了model.pkl

model1 = Pipeline([
    ('CountVectorizer', CountVectorizer()), 
    ('TfidfTransformer', TfidfTransformer()),  
    ('KNeighborsClassifier',  KNeighborsClassifier()),
    ])
model1.fit(traindata_data, traindata_label)


import pickle 
pickle.dump(model1, open("model.pkl","wb"))

并从app.py加载pickle文件:

model = pickle.load(open("./model.pkl","rb"))

0 个答案:

没有答案