0

Massive problems reading pickled files saved under python 3.6 env. Checked other similar questions on stckoverflow - didn't help

This is how we saved the files in python 3.6.

with open('sonde_adam_final.pkl', 'wb') as f:
    pickle.dump(sonde_data, f,protocol=2)

1st we tried with default protocol which defaults to version 3, then we tried protocol=2 - still no good.

This is how we try to open in python 3.6 env

sonde_data = pickle.load(open('sonde_adam_final.pkl', 'rb'), fix_imports=True, encoding='bytes')
Error: ModuleNotFoundError: No module named 'pandas.core.indexes'

sonde_data = pickle.loads(open('sonde_adam_final.pkl', 'rb'), fix_imports=True, encoding='bytes')
Error: TypeError: a bytes-like object is required, not '_io.BufferedReader'

sonde_data = pd.read_pickle(open('sonde_adam_final.pkl', 'rb''))

Error: TypeError: expected str, bytes or os.PathLike object, not _io.BufferedReader

sonde_data = pd.read_pickle('/home/vinorda/storm_predict/data/sonde_adam_final.pkl')

Error: ModuleNotFoundError: No module named 'pandas.core.indexes'

with open('/home/vinorda/storm_predict/data/sonde_adam_final.pkl', 'rb') as savefile:
    sonde_data = pd.read_pickle(savefile)

Error: TypeError: expected str, bytes or os.PathLike object, not _io.BufferedReader

with open('/home/vinorda/storm_predict/data/sonde_adam_final.pkl', 'rb') as savefile:
    sonde_data = pickle.load(savefile)

Error: ModuleNotFoundError: No module named 'pandas.core.indexes'

appreciate any help...

jedwards
  • 29,432
  • 3
  • 65
  • 92
  • I think your issue lies not in the pickle protocol (that should be autodetected), but in the difference in Pandas versions. If Pandas refactored their code (and [this related](https://stackoverflow.com/questions/37371451/importerror-no-module-named-pandas-indexes) suggests they have) you either need an older version of Pandas to unpickle it normally, or have Pandas try to unpickle it as suggested in the top answer of that linked related. – jedwards Jun 04 '18 at 03:02
  • I'm going to vote to close this as "already answered", but please comment if that solution doesn't work for you. – jedwards Jun 04 '18 at 03:03
  • Possible duplicate of [ImportError: No module named 'pandas.indexes'](https://stackoverflow.com/questions/37371451/importerror-no-module-named-pandas-indexes) – jedwards Jun 04 '18 at 03:04

0 Answers0