TheTank
TheTank

Reputation: 505

How to resolve ValueError: unsupported pickle protocol: 4

I am having a vague issue where protocol 2 or 4 both yield errors.

I have python 3.6 installed and working with protocol 4. But for some reason while running it reverts to python2.7 and I suspect that is why I am getting the Value Error.

Here is the error:

  File "prod1.py", line 126, in load_pickle
  data = pickle.load(f)
  File "/usr/lib64/python2.7/pickle.py", line 1378, in load
  return Unpickler(file).load()
  File "/usr/lib64/python2.7/pickle.py", line 858, in load
  dispatch[key](self)
  File "/usr/lib64/python2.7/pickle.py", line 886, in load_proto
  raise ValueError, "unsupported pickle protocol: %d" % proto
  ValueError: unsupported pickle protocol: 4

Please help.

Upvotes: 3

Views: 4417

Answers (1)

Noctis Skytower
Noctis Skytower

Reputation: 22001

Try adding this before all the other lines in your program:

#! /usr/bin/env python3

The change may help with running in the correct interpreter.

Reference: 3.4.2. Shebang Lines

Upvotes: 1

Related Questions