Any #Python devs in the house? I’m getting unpickling error A, which I’ve never seen before. I searched StackOverflow already, obv. It’s esp hard to troubleshoot because it’s in a Jupyter notebook environment controlled by my professor, so I can only change certain parts of the code. TA wasn’t much help—told me to install pickle. 🤦🏼♀️
@nicolemark I think it means that the scope when the pickle was written had a symbol ‘A’ in scope (maybe a class?) that is not in scope when you are trying to unpickle the file. So it doesn’t know how to use (probably call) A to reconstruct an object.
@nicolemark Is it possible that the file was saved with compression (like gzip) or from a library like joblib that has its own code for serialization/pickling? If so, matching the compression settings or reading the file with the same library used to write it may help.
@nicolemark Does that file work for others with that version of Python? It looks like it is corrupted or just created with a different version of pickle that isn't supported with what you're using.
@kleaders I don't have control over the environment because it's for a class, and I checed in with a few classmates. Two are having the same problem, but one is not. The one who was able to use it wrote the exact same code as I did.
@nicolemark@kleaders are you using the same version of python as your 2 classmates with the same problem? Is your classmate without the problem possibly on a different version of python? The results of pickling can vary across python versions so the version that made the pickle may work but a different version might not.
@nicolemark@kleaders rules that out then - I don't suppose one of you is on mac and others on windows or something like that? After that my bad guesses run out unfortunately.
@kimvanwyk@kleaders We’re all on Macs except one of the other people who couldn’t unpickle the file. They’re a pretty smart and diverse group, experience-wise, so I feel confident at this point that there’s an issue with the file.
@nicolemark@kleaders ah, sorry, my apology, from the vagaries of my Mastodon client I didn't realise I was asking a question that had already been asked and answered. Sorry to waste your time!
@nicolemark@kimvanwyk yeah I think it's a corrupted file. You can compare the shasums/file sizes on each system to see if something doesn't match up. But the answer probably will be to download again.
@nicolemark@willmcgugan pickle is quite fragile in my experience, it helps to only use pickled files across identical Python versions. Also, having exactly the same environment / packages on either side is important.
@nicolemark
Yeah, pretty sure the A is something in your data (or in what it is treating as your data), it isn't something that you'll find in answers about this. @willmcgugan
$ echo -n A > /tmp/pk
$ python3 -c 'import pickle; pickle.load(open("/tmp/pk", "rb"))'
Traceback (most recent call last):
File "<string>", line 1, in <module>
_pickle.UnpicklingError: invalid load key, 'A'.
There are different things an actual pickle will start with, but it looks like a modern one will usually begin with an 0x80 byte and not a printable character. (This probably doesn't narrow it down much further though.)
@eichin@willmcgugan Thank you! Regardless of whether that narrows it down, I’ve learned several new troubleshooting strategies that I’m saving for later.
Add comment