Skip to content

jupyter: kernelspecs library outputs incomplete list #8224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
williamstein opened this issue Mar 22, 2025 · 5 comments
Open

jupyter: kernelspecs library outputs incomplete list #8224

williamstein opened this issue Mar 22, 2025 · 5 comments

Comments

@williamstein
Copy link
Contributor

On my Dev machine (Ubuntu 22.04), the output of the kernelspecs package from @rgbkrk is incomplete:

Compare my machine:

~/cocalc/src$ jupyter kernelspec list
Available kernels:
  python3           /usr/local/lib/python3.10/dist-packages/ipykernel/resources
  bash              /usr/local/share/jupyter/kernels/bash
  ir                /usr/local/share/jupyter/kernels/ir
  ir-sage           /usr/local/share/jupyter/kernels/ir-sage
  javascript        /usr/local/share/jupyter/kernels/javascript
  julia-1.9         /usr/local/share/jupyter/kernels/julia-1.9
  octave            /usr/local/share/jupyter/kernels/octave
  python3-sage      /usr/local/share/jupyter/kernels/python3-sage
  python3-ubuntu    /usr/local/share/jupyter/kernels/python3-ubuntu
  sagemath          /usr/local/share/jupyter/kernels/sagemath

with the kernelspecs library

> Object.keys(await require("kernelspecs").findAll())
[
  'bash',
  'ir',
  'ir-sage',
  'javascript',
  'julia-1.9',
  'octave',
  'python3-sage',
  'python3-ubuntu',
  'sagemath'
]

This kernel:

python3           /usr/local/lib/python3.10/dist-packages/ipykernel/resources

which is actually the system default, is missing.

I realize that kernelspecs hasn't been touched in over 4 years. Maybe the jupyter kernel search algorithm or spec (if there is one) has changed?

@williamstein
Copy link
Contributor Author

williamstein commented Mar 22, 2025

This isn't particular impactful in the context of cocalc.com, because we have a curated list of kernels. Also, things seem fine on compute servers. But it would still be nice to sort this out. I greatly prefer using kernelspecs over say a shell call out to jupyter kernelspec list, since using kernelspecs is 10x - 100x faster...

@haraldschilly
Copy link
Contributor

On your machine, what does $ jupyter --paths say? I wonder if this actually a problem of https://github.com/nteract/jupyter-paths

@williamstein
Copy link
Contributor Author

Here are the two:

Image

jupyter --paths is essentially the same, so that doesn't seem to be the problem.

Basically jupyter kernelspec list is picking up "the system default kernel" (which jupyterlab etc uses by default, so pretty important!) at /usr/local/lib/python3.10/dist-packages/ipykernel/resources which is especially weird to me since that has only logos in it:

~/cocalc/src$ ls /usr/local/lib/python3.10/dist-packages/ipykernel/resources
logo-32x32.png  logo-64x64.png  logo-svg.svg

The path to this system kernel isn't even in the output of jupyter --paths. I suspect jupyter kernelspec just uses a different algorithm or definition than the kernelspecs library, or maybe Ubuntu patches it or something else...

@haraldschilly
Copy link
Contributor

Hmm, weird. Well, kernelspecs' code discards all spec dirs where there is no kernel.json file. That makes sense to me, though.

@williamstein
Copy link
Contributor Author

Hmm, weird. Well, kernelspecs' code discards all spec dirs where there is no kernel.json file.

Good job figuring that out.

That makes sense to me, though.

It makes sense, but it is also inconsistent with what upstream Jupyter (or Ubuntu?) actually does, so there is a bug somewhere. This probably arose out of some conflict in packaging policies, e.g., maybe in Ubuntu one package has files in several different directories, whereas in Jupyter kernels we think of everything in one directory.

Reading https://jupyter-client.readthedocs.io/en/5.2.1/kernels.html just makes me think Ubuntu is doing something weird/wrong...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants