
ローカルマシンで作成したpickleをColabで読み込もうとしたときに表題のエラー。
# ローカルマシン
df.to_pickle("df.pickle")
# Colab
df = pd.read_pickle("df.pickle")
Error: Unsupported Pickle Protocol 5
pickle5はpython3.8から導入されたらしい。
ローカルマシンは3.8.4だったので、Colabはpickle5が導入される前のバージョンなのかも?

PEP 574 – Pickle protocol 5 with out-of-band data | peps.python.org
This PEP proposes to standardize a new pickle protocol version, and accompanying APIs to take full advantage of it:
!python -V
Python 3.7.10
Colabでは3.7で、pickle5が導入される前のPythonバージョンになっていた。
別途 pickle5 のモジュールをColabにインストールする。

pickle5
Backport of the pickle 5 protocol (PEP 574) and other pickle changes
!pip install pickle5
あとはimportしてロードすればOK。
import pickle5
with open("df.pickle", "rb") as f:
df = pickle5.load(f)
df.head()
参考
Attention Required! | Cloudflare
コメント