sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.47k stars 485 forks source link

Sage's jupyter doesn't "talk" to a systemwide IRkernel R package #30120

Open 7822f248-ba56-45f1-ab3d-4de7482bdf9f opened 4 years ago

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 4 years ago

TL:DR : Sage's Jupyter cannot use a systemwide R IRkernel (correctly installed and usable from a systemwide jupyter notebook).

Current situation :

Kernels:

charpent@zen-book-flip:~$ jupyter kernelspec list
Available kernels:
  ir         /usr/local/share/jupyter/kernels/ir
  python3    /usr/share/jupyter/kernels/python3
charpent@zen-book-flip:~$ sage -jupyter kernelspec list
Available kernels:
  python3     /usr/local/sage-9/local/share/jupyter/kernels/python3
  sagemath    /usr/local/sage-9/local/share/jupyter/kernels/sagemath
  ir          /usr/local/share/jupyter/kernels/ir

Symptoms :

Attempts to install the r_jupyter spkg failed :

The availability of R from Sage's notebook should reduce the need for the systemwide Jupyter(ditto for the other Sage-created Jupyter kernels).

Alternatively, the availability of the Sage kernel from the systemwide notebook would reduce (eliminate ?) the need for Sages's Jupyter (this currently fails, the documentation can't be found during kernel's installation).

//Sidenote :// the r_jupyter spkg downloads the Github version of IRkernel. This is outdated, IRkernel being on CRAN since late 2019 : this version should probably be preferred, if only for stability/availability reasons

Depends on #30124

Component: notebook

Issue created by migration from https://trac.sagemath.org/ticket/30120

slel commented 4 years ago
comment:1

Workaround: install Sage's Jupyter kernel in systemwide Jupyter installation.

$ JUPTER_KERNELS=/path/to/jupyter/kernels

$ SAGE_LOCAL=`$ sage -c "print(SAGE_LOCAL)"`
$ SAGE_KERNEL=$SAGE_LOCAL/share/jupyter/kernels/sagemath

$ ln -s $SAGE_KERNEL $JUPYTER_KERNELS

To find out what to use for /path/to/jupyter/kernels:

$ jupyter kernelspec list

See also:

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 4 years ago
comment:2

Replying to @slel:

Workaround: install Sage's Jupyter kernel in systemwide Jupyter installation.

$ JUPTER_KERNELS=/path/to/jupyter/kernels

$ SAGE_LOCAL=`$ sage -c "print(SAGE_LOCAL)"`
$ SAGE_KERNEL=$SAGE_LOCAL/share/jupyter/kernels/sagemath

$ ln -s $SAGE_KERNEL $JUPYTER_KERNELS

Thanks ! This works.

To find out what to use for /path/to/jupyter/kernels:

$ jupyter kernelspec list

A bashism to find this programatically is :

jupyter kernelspec list| grep python3 | sed -re "s/[ \t]+/ /g" | cut -d " " -f 3 | sed "s/\/python3//"

If this can be generalized to our other supported platforms, this might allow to dispense with Jupyter in sage-the-distribution, in line with the current effort to (be able to) use a maximum of systemwide tools.

See also:

Interesting.

Do you think that this ticket should be :

Thank you again !

slel commented 4 years ago
comment:3

Do you think that this ticket should be:

  • Left open to work on using external kernels with Sage
  • Closed as invalid (if we move to "external" jupyter)
  • Be reworked to patch this "external" jupyter solution into Sage itself?

Document symlinking Jupyter kernels both ways between systemwide Jupyter and Sage's one.

Did you try symlinking the other way, i.e. find the IRkernel from your systemwide Jupyter and add a symlink to it in $SAGE_LOCAL/share/jupyter/kernels?

slel commented 4 years ago
comment:4

Related:

7822f248-ba56-45f1-ab3d-4de7482bdf9f commented 4 years ago
comment:5

Replying to @slel:

[ Snip... ]

Did you try symlinking the other way, i.e. find the IRkernel from your systemwide Jupyter and add a symlink to it in $SAGE_LOCAL/share/jupyter/kernels?

I tried that (documented in the description), and it doesn't work (same symptoms as with "normal" installation : R appears in the menu for "new sheet", opens a new (blank) tab, that remains totally inactive. No sifgn of life in the cosole where I have done "sagemath -n jupyter" either).

kiwifb commented 4 years ago
comment:6

Have you tried to set JUPYTER_PATH in the sage environment to point to the folder where the system's kernel are located?

https://jupyter-client.readthedocs.io/en/stable/kernels.html

mkoeppe commented 4 years ago

Dependencies: #30124

mkoeppe commented 3 years ago
comment:9

Setting new milestone based on a cursory review of ticket status, priority, and last modification date.