You should write the pickled data with a lower protocol number in Python 3. Python 3 introduced a new protocol with the number 3
(and uses it as default), so switch back to a value of 2
which can be read by Python 2.
Check the protocol
parameter in pickle.dump
. Your resulting code will look like this.
pickle.dump(your_object, your_file, protocol=2)
There is no protocol
parameter in pickle.load
because pickle
can determine the protocol from the file.
Related Posts:
- ValueError: unsupported pickle protocol: 3, python2 pickle can not load the file dumped by python 3 pickle?
- WinError 2 The system cannot find the file specified (Python)
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- Could not find a version that satisfies the requirement tensorflow
- sklearn error ValueError: Input contains NaN, infinity or a value too large for dtype(‘float64’)
- Could not find a version that satisfies the requirement tensorflow
- Local variable referenced before assignment?
- TypeError: write() argument must be str, not bytes (Python 3 vs Python 2 )
- Change figure size and figure format in matplotlib
- Type error Unhashable type:set
- TypeError: ‘_io.TextIOWrapper’ object is not subscriptable
- Not able to pip install pickle in python 3.6
- What is the meaning of “int(a[::-1])” in Python?
- dump() missing 1 required positional argument: ‘fp’ in python json
- Does python have header files like C/C++?
- How to open a file using the open with statement
- Relative imports – ModuleNotFoundError: No module named x
- Python Variable Declaration
- TypeError: ‘int’ object is not callable
- Best way to convert string to bytes in Python 3?
- PermissionError: [Errno 13] Permission denied
- What is setup.py?
- Cannot find module cv2 when using OpenCV
- ValueError: Unknown label type: ‘continuous’
- How to remove EOFError: EOF when reading a line?
- IndexError: tuple index out of range —– Python
- TypeError: cannot unpack non-iterable NoneType object
- Is there a ‘foreach’ function in Python 3?
- Python inline if statement
- How to copy a dictionary and only edit the copy
- How to print like printf in Python3?
- Why do I get “Pickle – EOFError: Ran out of input” reading an empty file?
- TypeError: ‘type’ object is not subscriptable when indexing in to a dictionary
- Invalid character in identifier
- pip or pip3 to install packages for Python 3?
- Convert list to tuple in Python
- ‘str’ object has no attribute ‘decode’. Python 3 error?
- How to find all the indexes of a recurring item in a list?
- How do you use subprocess.check_output() in Python?
- (Help) TypeError: ‘str’ object cannot be interpreted as an integer
- Why KeyError: 0
- How to create a new text file using Python
- Are dictionaries ordered in Python 3.6+?
- builtins.TypeError: must be str, not bytes
- takes 1 positional argument but 2 were given
- Python 3 ImportError: No module named ‘ConfigParser’
- Why am I getting this syntax error: keyword can’t be an expression
- Check string “None” or “not” in Python 2.7
- re.search().TypeError: cannot use a string pattern on a bytes-like object
- Add Legend to Seaborn point plot
- ctypes – Beginner
- How can I install Python’s pip3 on my Mac?
- how to update spyder on anaconda
- AttributeError(“‘str’ object has no attribute ‘read'”)
- Get ZeroDivisionError: float division in python
- TypeError: ‘encoding’ is an invalid keyword argument for this function
- ImportError: No module named scipy
- What is the Python 3 equivalent of “python -m SimpleHTTPServer”
- What does -> mean in Python function definitions?
- Pickle , read in data , unsupported pickle protocol: 3 python 2.7
- TypeError(“‘bool’ object is not iterable”,) when trying to return a Boolean
- “for line in…” results in UnicodeDecodeError: ‘utf-8’ codec can’t decode byte
- AttributeError(“‘str’ object has no attribute ‘read'”)
- How to use 2to3 properly for python?
- How to troubleshoot an “AttributeError: __exit__” in multiproccesing in Python?
- Why does using from __future__ import print_function breaks Python2-style print?
- Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings
- Python map object is not subscriptable
- .pyw files in python program
- Replacing a character from a certain index
- ImportError: No module named ‘google’
- How to read pickle file?
- Get a random sample with replacement
- NameError: global name ‘unicode’ is not defined – in Python 3
- Conda command is not recognized on Windows 10
- ImportError: No module named ‘django.core.urlresolvers’
- Numpy, multiply array with scalar
- How to do a Sigma in python 3
- Python 3: Multiply a vector by a matrix without NumPy
- How to fix “Can’t find a default Python” error
- TypeError: ‘newline’ is an invalid keyword argument for this function
- TypeError: coercing to Unicode: need string or buffer, list found
- environment variables PYSPARK_PYTHON and PYSPARK_DRIVER_PYTHON
- Python: urllib.error.HTTPError: HTTP Error 404: Not Found
- “This constructor takes no arguments” error in __init__
- TypeError: super() takes at least 1 argument (0 given) error is specific to any python version?
- ValueError: cannot switch from manual field specification to automatic field numbering
- How to embed image or picture in jupyter notebook, either from a local machine or from a web resource?
- Adding +1 to a variable inside a function
- Install py2exe for python 2.7 over pip: this package requires Python 3.3 or later
- How can I count time in Python 3?
- What is the correct format to write float value to file in Python
- Using strip() to clean up a string
- ImportError: No module named IPython
- “E: Unable to locate package python3-pip”
- Accessing dict_keys element by index in Python3
- Symbol not found: __PyCodecInfo_GetIncrementalDecoder
- KeyError: ‘plotly_domain’
- TypeError: ‘zip’ object is not subscriptable