notebook icon indicating copy to clipboard operation
notebook copied to clipboard

jupyter notebook list show error "json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)"

Open ttpro1995 opened this issue 5 years ago • 9 comments
trafficstars

In base conda environment, I run

jupyter notebook list

It show error

Traceback (most recent call last):
  File "/home/cpu11453/miniconda3/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 845, in launch_instance
    app.start()
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 2195, in start
    super(NotebookApp, self).start()
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 259, in start
    self.subapp.start()
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 596, in start
    serverinfo_list = list(list_running_servers(self.runtime_dir))
  File "/home/cpu11453/miniconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 2295, in list_running_servers
    info = json.load(f)
  File "/home/cpu11453/miniconda3/lib/python3.7/json/__init__.py", line 296, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/home/cpu11453/miniconda3/lib/python3.7/json/__init__.py", line 348, in loads
    return _default_decoder.decode(s)
  File "/home/cpu11453/miniconda3/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/home/cpu11453/miniconda3/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)

Expectation: list all running instance if any.

ttpro1995 avatar Nov 12 '20 03:11 ttpro1995

You can refer to this link.

sarveshggn avatar Nov 12 '20 06:11 sarveshggn

jupyter notebook list simply reads JSON files named nbserver-pid.json in the Jupyter runtime directory (found via jupyter --runtime). Check those files to ensure there's nothing out of the ordinary. The content should be JSON and resemble the following...

{
  "base_url": "/",
  "hostname": "localhost",
  "notebook_dir": "/Users/kbates/.jupyter",
  "password": false,
  "pid": 39736,
  "port": 8888,
  "secure": false,
  "sock": "",
  "token": "78905550521d33869297b7a8e0a7618ab990da77091f7764",
  "url": "http://localhost:8888/"
}

kevin-bates avatar Nov 12 '20 18:11 kevin-bates

i went there it was fine but i cant solve the problem yet

Ibn-mohey avatar Dec 07 '21 05:12 Ibn-mohey

Just create a folder in the Jupyter runtime directory. Backup by Moving all the .json files there. Then start a new notebook and try 'jupyter notebook list' again.

bf2harven avatar Feb 20 '22 19:02 bf2harven

I've run into this issue as well.

baileyji avatar Mar 09 '22 17:03 baileyji

I'm also seeing this, has anyone found a solution?

Edit: bf2harven's solution above worked for me, though its unclear why this is happening and whether it will happen again...

reinhold-willcox avatar Mar 17 '22 02:03 reinhold-willcox

Temporary solution of

  1. Moving all the jsons from the folder resulting in jupyter --runtime-dir to another folder
  2. start new jupyter notebook
  3. jupyter notebook list seem to resolve decode error but has a blank input just as jupyter lab list jupyter server list however runned instances are seen in ps aux | grep jupyter which is suprising due to https://github.com/jupyter/notebook/issues/2254#issuecomment-317709079

GrigoriiTarasov avatar Oct 29 '22 19:10 GrigoriiTarasov

I just deleted the folder: /home/USER/.local/share/jupyter And restarted jupyter lab. Then it was working for me. Jupyter lab will create this folder again after starting. But attention: Some settings might get lost! It is therefore maybe worth saving the folder just in case you want to recover it again.

mpriessner avatar Feb 16 '23 14:02 mpriessner

I had an empty page_config.json in ~/.jupyter/labconfig removing it solved the issue of jupyter lab throwing JSONDecodeError

Laubeee avatar Mar 12 '24 12:03 Laubeee