+4 votes
in Programming Languages by (73.8k points)

I am trying to read a pickle file using the following code, but it gives error: "ValueError: unsupported pickle protocol: 5". How can I solve this error?

    with open('existing_videos.pkl', 'rb') as fh:
        existing_vids = pickle.load(fh)

1 Answer

+1 vote
by (348k points)
selected by
 
Best answer

It seems that your pickle file 'existing_videos.pkl' was saved using protocol=5 and Python 3.5.3 does not support pickle protocol=5. You can fix the error by doing the followings:

  • Install pickle5 on your system.

pip install pickle5

  • import pickle5 instead of pickle in your code.

import pickle5 as pickle


...