jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.71k stars 4.95k forks source link

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

Open ttpro1995 opened 3 years ago

ttpro1995 commented 3 years ago

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.

sarveshggn commented 3 years ago

You can refer to this link.

kevin-bates commented 3 years ago

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/"
}
Ibn-mohey commented 2 years ago

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

bf2harven commented 2 years ago

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.

baileyji commented 2 years ago

I've run into this issue as well.

reinhold-willcox commented 2 years ago

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...

GrigoriiTarasov commented 2 years ago

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

mpriessner commented 1 year ago

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.

Laubeee commented 7 months ago

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