79649940

Date: 2025-06-02 15:42:42
Score: 0.5
Natty:
Report link

Turns out that how you pickle makes a difference. If the dataframe was pickled through a pickle dump, it works:

with open('test.pkl','wb') as handle:
    pickle.dump(df,handle)

On second computer, in different file:

with open('path/to/test.pkl','rb') as handle:
    data = pickle.load(handle)
# or:
data = pd.read_pickle('path/to/test.pkl')

However: If you select pickle.HIGHEST_PROTOCOL as the protocol for dumping, the same error will arise no matter how the pickle is loaded

# Gave pickle with same missing module error on loading:
with open('test.pkl','wb') as handle:
    pickle.dump(df,handle,protocol=pickle.HIGHEST_PROTOCOL)

I have not done any investigation on why the error appears and came to this solution simply through trial and error.

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: vboettcher