0

while trying to unpickle serialized data I run into a ImportError, albeit the needed is loaded.

From this question I learnd that pickle expects the same package structure during unpickling as the package structure used during pickeling.

Is there some way to extract the expected package layout from pickled objects to restore the original package layout and solve this issue? Help would be greatly appreciated, as otherwise I had to test several hundred revisions of a project to finde the one working for unpickeling the data.

EDIT Tanks for the hint. Of course it is ment to be package structure not path structure.

Community
  • 1
  • 1
rikisa
  • 301
  • 2
  • 9
  • 1
    It's quite easy: `with open('your_file.pickle', 'rb') as f: contents = f.read()` and then display `contents` and you should see a lot of binary data but also something like `package.module.submodule.class_name/function_name` Those paths describe the package structure needed to deserialize the contents. Note that the paths don't matter, what matters is the package structure. – Bakuriu Oct 31 '16 at 12:45
  • Thanks @Bakuriu. For me the output it is a bit more cryptic (maybe because I use the lowest Protocol/ASCII?) but i see the point. You are right. I meant package structure but this wasn't what I wrote. On a sidenote: I just realized that ImportError can be also read as ImporTerror... ;) – rikisa Oct 31 '16 at 14:56

0 Answers0