Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook running servers list - ValueError: No JSON object could be decoded

I wanted to get the list of running servers using the command-line:

jupyter notebook list

I get an error:

Traceback (most recent call last):
  File "/home/sarah/anaconda3/envs/py27/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/notebook/notebookapp.py", line 1571, in start
    super(NotebookApp, self).start()
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/notebook/notebookapp.py", line 483, in start
    serverinfo_list = list(list_running_servers(self.runtime_dir))
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/site-packages/notebook/notebookapp.py", line 1667, in list_running_servers
    info = json.load(f)
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/json/__init__.py", line 291, in load
    **kw)
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/sarah/anaconda3/envs/py27/lib/python2.7/json/decoder.py", line 382, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

How to correct it? I don't understand the reason.

like image 774
SarahData Avatar asked Jun 07 '18 14:06

SarahData


1 Answers

The logic for determining running notebook servers relies on iterating over all files in runtime-dir with prefix "nbserver-" and trying to load as JSON. Therefore, a malformed file in this folder may be causing the JSON error. Solved this by deleting all files under the Jupyter runtime-dir:

$ jupyter --runtime-dir
/home/user/.local/share/jupyter/runtime
$ cd $(jupyter --runtime-dir) && rm *
like image 162
Rafael Ribeiro Avatar answered Nov 14 '22 21:11

Rafael Ribeiro