millejoh / emacs-ipython-notebook

Jupyter notebook client in Emacs
http://millejoh.github.io/emacs-ipython-notebook/
GNU General Public License v3.0
1.47k stars 122 forks source link

Invalid Token/Notebook server error #790

Closed jasontuna closed 3 years ago

jasontuna commented 3 years ago

Problem description

Any attempt to start a notebook server or logging into a server started in a terminal, e.g., through calling 1] ein:run 2] ein:login 3] C-c C-o with an open ipynb file 4] or other calls using ein:notebook...

results in a similar error.

I have cleaned out any jupyter notebook settings. I have also used emacs 27, and 28. I have cleaned out my init, reinstalled everything, etc... I have also tried setting a password for the notebook, and that did not help either.

It seems that json-parse-string is erroring out on "[NbserverListApp] WARNING | Config option kernel_spec_manager_class not recognized by NbserverListApp." :object-type plist :array-type array :null-object nil :false-object :json-false

Steps to reproduce the problem

calling any interaction, or creating a notebook results in the debugger output;

Debugger entered--Lisp error: (json-parse-error "invalid token near 'NbserverListApp'" "" 1 16 16) json-parse-string("[NbserverListApp] WARNING | Config option kernel_spec_manager_class not recognized by NbserverListApp." :object-type plist :array-type array :null-object nil :false-object :json-false) ein:jupyter-crib-running-servers() ein:notebooklist-ask-url-or-port() byte-code("\301 \302\10\205\n\0\303\304!\10\205\21\0\303\305!\306BBBB\207" [current-prefix-arg ein:notebooklist-ask-url-or-port #f(compiled-function (buffer url-or-port) #<bytecode 0x100e3dd>) read-no-blanks-input "Cookie name: " "Cookie content: " (nil)] 5) call-interactively(ein:login record nil) command-execute(ein:login record) execute-extended-command(nil "ein:login" "ein:login") funcall-interactively(execute-extended-command nil "ein:login" "ein:login") call-interactively(execute-extended-command nil nil) command-execute(execute-extended-command)

System info:

("EIN system info"
 :emacs-version
 "GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0)
 of 2020-09-19"
 :window-system x
 :emacs-variant nil
 :build
 "--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib --infodir=/usr/share/info --mandir=/usr/share/man --enable-locallisppath=/etc/emacs:/usr/local/share/emacs/27.1/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/27.1/site-lisp:/usr/share/emacs/site-lisp --program-suffix=27 --with-modules --with-file-notification=inotify --with-mailutils --with-harfbuzz --with-json --with-x=yes --with-x-toolkit=gtk3 --with-lcms2 --with-cairo --with-xpm=yes --with-gif=yes --with-gnutls=yes --with-jpeg=yes --with-png=yes --with-tiff=yes --with-xwidgets 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs27-bifpWT/emacs27-27.1~1.git86d8d76aa3=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie'"
 :os
 (:uname
  "Linux flagpoles 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
"
  :lsb-release
  "No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:    20.04
Codename:   focal
")
 :jupyter
 "jupyter core     : 4.7.1
jupyter-notebook : 6.2.0
qtconsole        : 5.0.2
ipython          : 7.21.0
ipykernel        : 5.3.4
jupyter client   : 6.1.7
jupyter lab      : 2.2.6
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.2
traitlets        : 5.0.5
"
 :image-types
 (svg png gif tiff jpeg xpm xbm pbm)
 :image-types-available
 (svg png gif tiff jpeg xpm xbm pbm)
 :request-backend curl
 :ein
 (:version "20210228.15"
       :source-dir "/home/jtuna/.emacsconfs/jupyteremacs/elpa/ein-20210228.15/")
 :lib
 ((:name "websocket"
     :path "~/.emacsconfs/jupyteremacs/elpa/websocket-20210110.17/websocket.elc"
     :featurep t
     :version-var websocket-version
     :version "1.12")
  (:name "anaphora"
     :path "~/.emacsconfs/jupyteremacs/elpa/anaphora-20180618.2200/anaphora.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "request"
     :path "~/.emacsconfs/jupyteremacs/elpa/request-20210214.37/request.elc"
     :featurep t
     :version-var request-version
     :version "0.3.3")
  (:name "deferred"
     :path "~/.emacsconfs/jupyteremacs/elpa/deferred-20170901.1330/deferred.elc"
     :featurep t
     :version-var deferred:version
     :version "0.5.0")
  (:name "polymode"
     :path "~/.emacsconfs/jupyteremacs/elpa/polymode-20200606.1106/polymode.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "dash"
     :path "~/.emacsconfs/jupyteremacs/elpa/dash-20210308.2109/dash.elc"
     :featurep t
     :version-var nil
     :version nil)
  (:name "with-editor"
     :path "~/.emacsconfs/jupyteremacs/elpa/with-editor-20210117.2008/with-editor.elc"
     :featurep nil
     :version-var nil
     :version nil)))

Logs:

ein:log-all:

10:34:00:834: [warn] ein:jupyter-default-kernel: (json-readtable-error 76) @#<buffer *scratch*>
10:35:10:140: [warn] ein:dev-packages: Don’t call me! @#<buffer  *temp*>
dickmao commented 3 years ago

How attached are you to your $HOME/.jupyter/jupyter_notebook_config.py? If not at all, or if you don't even know what that is, perhaps you could:

mv $HOME/.jupyter/jupyter_notebook_config.py $HOME/.jupyter/backup.jupyter_notebook_config.py
jupyter notebook --generate-config
jupyter kernelspec list --json

If that last command, returns valid json, then you are home free.

jasontuna commented 3 years ago

How attached are you to your $HOME/.jupyter/jupyter_notebook_config.py? If not at all, or if you don't even know what that is, perhaps you could:

mv $HOME/.jupyter/jupyter_notebook_config.py $HOME/.jupyter/backup.jupyter_notebook_config.py
jupyter notebook --generate-config
jupyter kernelspec list --json

If that last command, returns valid json, then you are home free.

Prior to ticket submission, I had already deleted it, and generated a new config. The error is that when running

jupyter kernelspec list --json

for many installations, the output will have a warning prior to valid json in the beginning. For me it is,

*[ListKernelSpecs]* WARNING | Config option kernel_spec_manager_class not recognized by ListKernelSpecs.

prior to outputting valid JSON.

In particular, ein assumes that "jupyter kernelspec list --json" will always output json. Sure I can delete the associated jupyter_config.json which was installed by anaconda that has { "JupyterApp": { "kernel_spec_manager_class": "nb_conda_kernels.CondaKernelSpecManager" } } which is the offending kernelspec, but it would seem warnings should not break the installation. Of course it would make more sense for "jupyter kernelspec list --json" to output json according to spec also ...

dickmao commented 3 years ago

Given most users, including myself, are inclined to fire-and-forget github issues, I sort of make a summary judgment and preemptively close them out. But yes, emacs should disregard the stderr of those jupyter cli calls. Commit 147940d