Home > Software design >  AttributeError: Can't get attribute '_unpickle_block'
AttributeError: Can't get attribute '_unpickle_block'

Time:02-12

While using:

with open("data_file.pickle", "rb") as pfile:
     raw_data = pickle.load(pfile)  

I get the error:

AttributeError: Can't get attribute '_unpickle_block' on <module 'pandas._libs.internals' from '/opt/conda/lib/python3.8/site-packages/pandas/_libs/internals.cpython-38-x86_64-linux-gnu.so'>

Another answer to a similar question suggests checking the version of pickle I am using. It is the same on my machine, where I developed the code and on server, where I am running the code. I have searched everywhere with no answers. Please help.

CodePudding user response:

I don't think the problem is pickle module but Pandas version. Your file was probably created with an older version of Pandas. Now you use a newer version, pickle can't "deserialize" the object because the API change.

Try to downgrade your Pandas version and reload file. You can also try to use pd.read_pickle.

  • Related