程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

An error in pickle serialization and deserialization model caused by pandas version difference

編輯:Python

Error description

Error reporting keyword : Can't get attribute '_unpickle_block' pandas._libs.internals internals.cpython-38-x86_64-linux-gnu.so

Error report detailed log :

File "/home/xxxxx-yyyyy/PycharmProjects/xxxxx/nad_num_predict_service_03.py", line 31, in predict
loaded_model = ARIMAResults.load('model/arima_model.pkl')
File "/home/xxxxx-yyyyy/anaconda3/lib/python3.8/site-packages/statsmodels/base/model.py", line 2239, in load
return load_pickle(fname)
File "/home/xxxxx-yyyyy/anaconda3/lib/python3.8/site-packages/statsmodels/iolib/smpickle.py", line 42, in load_pickle
return pickle.load(fin)
AttributeError: Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' from '/home/xxxxx-yyyyy/anaconda3/lib/python3.8/site-packages/pandas/_libs/internals.cpython-38-x86_64-linux-gnu.so'>

The reason for the error

pickle When serializing and deserializing models , The use of pandas Errors caused by version inconsistencies . keep pandas The version is the same .

An example of specific error reporting

Virtual environment is not installed gunicorn, In virtual environment pandas edition =1.4.0,Anaconda Python The environment has gunicorn, And pandas edition =1.1.3.
Use directly in the virtual environment python The command runs flask web Normal operation of the project , The serialization model is normal (save model).
When used in virtual environments gunicorn Run the same flask web Project time , Deserialization model (load model) Report the above error . Because of this gunicorn yes Anaconda Python Package for environment , Will reference it Anaconda Python In the environment pandas, It is related to pandas Version inconsistency .

reference

https://stackoverflow.com/que...
https://stackoverflow.com/que...
https://stackoverflow.com/que...


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved