1

I would like to try the C++ kernel in Jupyter notebooks.

I am on Ubuntu 22.04.01. The existing answer cover Windows which was not supported at the time.

I already have a bunch of conda environments, mainly Python but a couple of Julia kernels as well. I normally launch Jupyter Notebooks from the Anaconda Navigator: upon clicking on the "New" I see all these environments (Julia 1.8.1, Python 3 ipykernel, as well as the conda environments). Once the new notebook is created, I find the them all again under Kernels / change Kernel menu.

To get a C++ kernel, I followed the steps in Xeus-Cling:Run C++ code in Jupyter notebook.

To summarise:

conda create -n xeus-cling
source activate xeus-cling

hence creating and activating a new conda environment (NOTE: I tried it all again using conda activate instead of source activate , although I believe they should be equivalent, are they not).

Further I install Xeus-cling, as per instructions

conda install -c conda-forge xeus-cling

and that should be it. I then go

source activate xeus-cling
jupyter-notebook

but contrary to the snapshot in the article, there is not trace of any C++ kernel, nor of the recenty create Xeus-cling conda environment (which however shows up if I issue conda env list.

When creating a new environment in the past, it would not show on the Jupyter Notebook "New" tab until ipykernel was installed, I guess this should be taken care in this case somehow by xeus-cling, but I am clearly not making it work.

If it could be of any relevance, the first time I tried the command jupyter notebooks got unrecognised. I installed with sudo apt and it did open a notebook, without C++ kernels. I deactivated/deleted this environment, and upon creating a new one, the command jupyter notebooks got recognised, which puzzled me-

Cjmarkham
  • 9,484
  • 5
  • 48
  • 81
user37292
  • 248
  • 2
  • 12
  • 1
    As per duplicate, the environment with `jupyter` and `nb_conda_kernels` should be activated, not the kernel. The kernel will be discovered automatically with `xeus-cling` - no need for any additional packages (e.g., `ipykernel` which is for Python kernels and not relevant). – merv Jan 15 '23 at 19:22
  • ok thanks, the bottom lie here is installing `nb_conda_kernels`, to my partial defence this is not menyioned in the tutoral I linked, thanks a lot – user37292 Jan 16 '23 at 23:07
  • No worries - unfortunately there's a lot of outdated and half-baked info out there on best practices for Conda + Jupyter. Once bad practices get entrenched, it's rather difficult getting better info into prominence. – merv Jan 17 '23 at 00:15
  • i see, thanks again your input was very useful – user37292 Jan 17 '23 at 13:49

0 Answers0