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, in Solus selecting one or the other doesn't change the Python version that is used. 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`.
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.
EDIT: Please note that this actually only solves the issue when running the Python 2 version of the notebook, i.e. `jupyter notebook`. If running `jupyter notebook3` or `jupyter3 notebook3`, then all kernels use Python 3, including the Python 2 kernel. I didn't find what to put in the Python 2 kernel.json to call specifically Python 2. `python2` does not work, it still calls Python 3 in that case.