Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read pickle file #4843

Closed
ronyarmon opened this issue Aug 28, 2019 · 2 comments
Closed

Can't read pickle file #4843

ronyarmon opened this issue Aug 28, 2019 · 2 comments

Comments

@ronyarmon
Copy link

I have no problem reading pickle files with pandas (pd.read_pickle(filename)) using python on the command line (3.7.3; Ubuntu 19.04) but when trying load the very same file from the terminal with ipython (or in a notebook I'm getting:

ValueError: unsupported pickle protocol: 4
The full traceback:

ValueError Traceback (most recent call last)
in ()
----> 1 data=pd.read_pickle ('sentences.pkl')

/home/rony/.local/lib/python2.7/site-packages/pandas/io/pickle.pyc in read_pickle(path, compression)
177 lambda f: pc.load(f, encoding=encoding, compat=True))
178 try:
--> 179 return try_read(path)
180 except Exception: # noqa: E722
181 if PY3:

/home/rony/.local/lib/python2.7/site-packages/pandas/io/pickle.pyc in try_read(path, encoding)
175 except Exception: # noqa: E722
176 return read_wrapper(
--> 177 lambda f: pc.load(f, encoding=encoding, compat=True))
178 try:
179 return try_read(path)

/home/rony/.local/lib/python2.7/site-packages/pandas/io/pickle.pyc in read_wrapper(func)
146 is_text=False)
147 try:
--> 148 return func(f)
149 finally:
150 for _f in fh:

/home/rony/.local/lib/python2.7/site-packages/pandas/io/pickle.pyc in (f)
175 except Exception: # noqa: E722
176 return read_wrapper(
--> 177 lambda f: pc.load(f, encoding=encoding, compat=True))
178 try:
179 return try_read(path)

/home/rony/.local/lib/python2.7/site-packages/pandas/compat/pickle_compat.pyc in load(fh, encoding, compat, is_verbose)
225 up.is_verbose = is_verbose
226
--> 227 return up.load()
228 except (ValueError, TypeError):
229 raise

/usr/lib/python2.7/pickle.pyc in load(self)
862 while 1:
863 key = read(1)
--> 864 dispatchkey
865 except _Stop, stopinst:
866 return stopinst.value

/usr/lib/python2.7/pickle.pyc in load_proto(self)
890 proto = ord(self.read(1))
891 if not 0 <= proto <= 2:
--> 892 raise ValueError, "unsupported pickle protocol: %d" % proto
893 dispatch[PROTO] = load_proto
894

ValueError: unsupported pickle protocol: 4

A similar issue pertaining to Python 2/3 was closed but mine seem to differ as I'm able to read the pickle file with python but not with ipython.

@MPrazzoli
Copy link

have you find any solutions? I am in the same situation you described, I want to unpickle file directly in Jupyter, but kernel always died after I try to plot the dataframe already retrieved from the pickle object

@kevin-bates
Copy link
Member

This sounds like something that should be opened in the IPython repo since the kernel is having the issue.

Should we find a link back to this repository, we can re-open this then.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants