jupyter
jupyter copied to clipboard
Emacs 27 json-read: JSON readtable error: 76
Trying to move from ob-ipython to emacs-jupyter, I am having trouble getting it to run.
My main environment that I wish to work from is Anaconda on a Linux machine. I do a minimal install of emacs-jupyter with use-package:
(use-package emacs-jupyter
:ensure t
)
Emacs claims it installed jupyter just fine, but when trying to run the REPL, I get the error message:
json-read: JSON readtable error: 76
...rather cryptic, I think. I have not een able to find out whether emacs-jupyter finds the Anaconda jupyter kernels and interpreters, but org-babel also does not understand any jupyter-XXX named kernels even though I did
(org-babel-do-load-languages
'org-babel-load-languages
'((R . t)
(python . t)
;;(ipython . t)
(latex . t)
(ditaa . t)
(shell . t)
(jupyter . t)
))
(org-babel-jupyter-override-src-block 'python)
...with no luck. What am I doing wrong?
Can you try loading package jupyter
instead of emacs-jupyter
? I use the following
(use-package jupyter
:after (ob-jupyter ob-python)
:config
(setq jupyter-api-authentication-method 'password)
(setq jupyter-eval-use-overlays nil)
(setq org-babel-default-header-args:jupyter-python '((:session . "/jpy:localhost#8888:py")
(:kernel . "conda-env-edge-py")
(:async . "yes")
(:pandoc t)))
(add-to-list 'savehist-additional-variables 'jupyter-server-kernel-names)
(setq ob-async-no-async-languages-alist '("jupyter-python"))
(add-to-list 'org-structure-template-alist '("j" . "src jupyter-python")))
Thanks @gmoutso , I tried basically copying your setup and removing my own, and tried to M-x jupyter-run-repl, but again, I get a "JSON readtable error: 76".
When I attempt to create an org source block and press C-c ' , I get the error "no such language mode: jupyter-python-mode".
Can you also load the libraries ob-jupyter and ob-python with use-package or require before you C-c ' the block?
The "no such language mode" might mean you need
(org-babel-do-load-languages
'org-babel-load-languages
'( (C . t) (python . t) (emacs-lisp . t) (dot . t) (plantuml . t)
(jupyter . t)
))
I don't know why I don't need it (loaded by ob-jupyter?).
Can you remove the org-babel-default-header-args:jupyter-python line that I wrote above (you would not have a ipykernel called conda-env-edge-py like I have anyway) ?
Can you run jupyter kernelspec list --json
on the command line?
I had the same issue. Running jupyter kernelspec list --json
showed a warning message:
[ListKernelSpecs] WARNING | Config option `kernel_spec_manager_class` not recognized by `ListKernelSpecs`.
{
"kernelspecs": {
"python3": {
"resource_dir": "/home/jason/anaconda3/share/jupyter/kernels/python3",
"spec": {
"argv": [
"/home/jason/anaconda3/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"env": {},
"display_name": "Python 3",
"language": "python",
"interrupt_mode": "signal",
"metadata": {}
}
}
}
}
It turned out there was a config file ~/anaconda3/etc/jupyter/jupyter_config.json
that had a bad configuration line in it. It's probably a result of a configuration option getting removed in a new version of nb_conda_kernels or something. Getting rid of that line made the warning go away and suddenly I don't get the error 76.
Calling jupyter kernelspec list --json --log-level=50
in the jupyter-available-kernelspecs
returns the JSON without the warning message, fyi.
@Jason-S-Ross The same was the root of my problem, it seems!
I wonder if this is something that would be worth adding to the documentation? In general, how to set it up with Conda? It's not super hard when one knows how to, but it can be pretty hard to figure out, and especially, this bug was really hard to track down.
I don't know why I have this kind of error, with other packages, also.
For example, org-roam-capture gives me:
user-error: JSON readtable error: 122.
Very annoying. That doesn't happen in my laptop, and pretty much it's the same linux and config file distributions. Although both have it's tweaks. Nothing I believe should have to with JSON handling.
I made sure to delete json related packages, indium, and javascript related modes. No success.
It's a little strange, but the problem is the following:
Install jupyter in your system, and guarantee it's usable by your emacs environment.
It's a chain of dependencies breakage.
The solution I found in this thread https://github.com/syl20bnr/spacemacs/issues/9941#
Try my fix solution below
its the following code that cause error
(jupyter-read-plist-from-string
(or (jupyter-command "kernelspec" "list" "--json")
(error "Can't obtain kernelspecs from jupyter shell command")
you can find this in emacs-jupyter/jupyter-kernelspec.el
(defun jupyter-available-kernelspecs (&optional refresh)
"Get the available kernelspecs.
Return an alist mapping kernel names to (DIRECTORY . PLIST) pairs
where DIRECTORY is the resource directory of the kernel and PLIST
is its kernelspec plist. The alist is formed by parsing the
output of the shell command
jupyter kernelspec list
By default the available kernelspecs are cached. To force an
update of the cached kernelspecs, give a non-nil value to
REFRESH.
If the `default-directory' is a remote directory, return the
mapping for the kernelspecs on the remote host. In this case,
each DIRECTORY will be a remote file name."
(let ((host (or (file-remote-p default-directory) "local")))
(or (and (not refresh) (gethash host jupyter--kernelspecs))
(let ((specs (plist-get
(jupyter-read-plist-from-string
(or (jupyter-command "kernelspec" "list" "--json")
(error "Can't obtain kernelspecs from jupyter shell command")))
:kernelspecs)))
(puthash
host (cl-loop
for (name spec) on specs by #'cddr
for dir = (concat (unless (equal host "local") host)
(plist-get spec :resource_dir))
collect (cons (substring (symbol-name name) 1)
(cons dir (plist-get spec :spec))))
jupyter--kernelspecs)))))
JSON readtable error: 76 occurs when
(jupyter-command "kernelspec" "list" "--json")
output warning as followed
[ListKernelSpecs] WARNING | Kernel Provisioning: The 'local-provisioner' is not found. This is likely due to the presence of multiple jupyter_client distributions and a previous distribution is being used as the source for entrypoints - which does not include 'local-provisioner'. That distribution should be removed such that only the version-appropriate distribution remains (version >= 7). Until then, a 'local-provisioner' entrypoint will be automatically constructed and used.
The candidate distribution locations are: ['/home/awannaphasch2016/anaconda3/envs/py38/lib/python3.8/site-packages/jupyter_client-6.1.12.dist-info', '/home/awannaphasch2016/anaconda3/envs/py38/lib/python3.8/site-packages/jupyter_client-7.1.0.dist-info']
{
"kernelspecs": {
"python3": {
"resource_dir": "/home/awannaphasch2016/anaconda3/envs/py38/share/jupyter/kernels/python3",
"spec": {
"argv": [
"/home/awannaphasch2016/anaconda3/envs/py38/bin/python",
"-m",
"ipykernel_launcher",
"-f",
"{connection_file}"
],
"env": {},
"display_name": "Python 3 (ipykernel)",
"language": "python",
"interrupt_mode": "signal",
"metadata": {
"debugger": true
}
}
}
}
}
follow the instruction and only keep jupyter version > 7 will remove the warning and jupyter-read-plist-from-string
will no longer produce error.
I am hitting this after upgrade the system (archlinux) jupyter_client 7.3.1 -> 7.3.2.
I also had the problem after the upgrade of jupyter_client from 7.3.1 to 7.3.2. There is an issue in version 7.3.2 and it is fixed in version 7.3.3 (see links below). I can start jupyter kernel after use the latest version of jupyter_client.
https://github.com/jupyter/jupyter_client/issues/800 https://github.com/jupyter/jupyter_client/pull/801
I confirm jupyter kernel starting correctly with jupyter_client==7.3.3
Thank you very much.
On mar 07 giu 2022 at 06:07, mk0417 @.***> wrote:
I also had the problem after the upgrade of jupyter_client from 7.3.1 to 7.3.2. There is an issue in version 7.3.2 and it is fixed in version 7.3.3 (see links below). I can start jupyter kernel after use the latest version of jupyter_client.
jupyter/jupyter_client#800 jupyter/jupyter_client#801
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.