When installing `python-ipykernel`, two `kernel.json` files get created, one for Python 2 ( in `/usr/share/jupyter/kernels/python2`) and one for Python 3 (in `/usr/share/jupyter/kernels/python3`). Jupyter (`python-jupyter_client`) uses them to identify the available kernels (see the [[ https://jupyter-client.readthedocs.io/en/stable/kernels.html#kernelspecs | documentation ]]). These json files have a key called `argv` which the documentation describes as `A list of command line arguments used to start the kernel`.
The issue in Solus is that for both kernels, `argv` contains `python`.
The problem became apparent when I was packaging `python-notebook` (for T5049). Using the notebook, the user should be able to dynamically switch between the Python 2 and the Python 3 kernels at runtime. However, selecting one or the other doesn't change the Python version that is used. If notebook is launched with Python 3 (`jupyter notebook3`), then both the python2 and python3 kernels use Python 3. If notebook is launched with Python 2 (`jupyter notebook`), then both the python2 and python3 kernels use Python 2.
This can be checked by running the following cell in the notebook:
By manually editing the `kernel.json` file of the Python 3 kernel such that it contains `python3` instead of just `python` in `argv`, the issue is fixed and the kernels can be dynamically changed at runtime when running `jupyter notebook`. Please not that it does not solve it when running `jupyter notebook3` in which case the Python 2 kernel will still use Python 3, but the usual known command to run notebook is `jupyter notebook`.
To solve the issue, one way would be to change the `package.yml` or include a patch. I just checked [[ https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/python-ipykernel | how they do it on Arch ]], and the script indeed manually changes the kernel.json file for the Python 2 kernel.