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

JSONDecodeError when closing notebook #317

Closed
jmarcedwards opened this issue Aug 30, 2020 · 4 comments · Fixed by #332
Closed

JSONDecodeError when closing notebook #317

jmarcedwards opened this issue Aug 30, 2020 · 4 comments · Fixed by #332
Assignees
Labels
Milestone

Comments

@jmarcedwards
Copy link

Description

What steps will reproduce the problem?

I am new to Spyder & the Jupyter plugin. I was just trying to close a notebook, and this error window popped up.

Traceback

  File "/Users/marcedw/opt/anaconda3/lib/python3.7/site-packages/spyder_notebook/widgets/notebooktabwidget.py", line 214, in close_client
    client.shutdown_kernel()
  File "/Users/marcedw/opt/anaconda3/lib/python3.7/site-packages/spyder_notebook/widgets/client.py", line 312, in shutdown_kernel
    kernel_id = self.get_kernel_id()
  File "/Users/marcedw/opt/anaconda3/lib/python3.7/site-packages/spyder_notebook/widgets/client.py", line 291, in get_kernel_id
    sessions = json.loads(sessions_response.content.decode())
  File "/Users/marcedw/opt/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/Users/marcedw/opt/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/marcedw/opt/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Versions

  • Spyder version: 4.1.4
  • Python version: 3.7.6
  • Qt version: 5.12.9
  • PyQt5 version: 5.12.3
  • Operating System: Darwin 19.6.0

Dependencies


# Mandatory:
applaunchservices >=0.1.7      :  0.2.1 (OK)
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.5.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.17.0 (OK)
jedi =0.17.1                   :  None (OK)
nbconvert >=4.0                :  5.6.1 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
parso =0.7.0                   :  0.7.0 (OK)
pexpect >=4.4.0                :  4.8.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.7.2 (OK)
pygments >=2.0                 :  2.6.1 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.34.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  0.7.2 (OK)
qtconsole >=4.6.0              :  4.7.6 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.2;<1.10.0 :  1.9.3 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.1 (OK)

# Optional:
cython >=0.21                  :  0.29.21 (OK)
matplotlib >=2.0.0             :  3.1.3 (OK)
numpy >=1.7                    :  1.18.1 (OK)
pandas >=0.13.1                :  1.1.1 (OK)
scipy >=0.17.0                 :  1.5.2 (OK)
sympy >=0.7.3                  :  1.6.2 (OK)

# Spyder plugins:
spyder_notebook                :  0.3.0 (OK)
@juanis2112
Copy link

juanis2112 commented Aug 30, 2020

Hi @jmarcedwards thanks for reporting this. @jitseniesen can you please take a look at this?

@ccordoba12 ccordoba12 transferred this issue from spyder-ide/spyder Sep 30, 2020
@major-s
Copy link

major-s commented Oct 15, 2020

I experience the same JSON error running Spyder on Window 10, only the last line differs:
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

@jitseniesen jitseniesen changed the title Trying to close Jupyter Notebook JSONDecodeError when closing notebook Oct 27, 2020
@jitseniesen
Copy link
Member

I think Spyder can ignore this error, but I want to consider it a bit more because I don't understand exactly what is happening.

@jitseniesen jitseniesen added this to the v0.3.1 milestone Oct 27, 2020
@jitseniesen
Copy link
Member

It looks like there is a bug in the code introduced in PR #232, in that the plugin tries to decode the server response before checking the response status. It's plausible that if the response status indicates an error, the response itself is incorrect or incomplete or empty, and that would explain the error message. I will fix this and hopefully that will resolve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants