This document gives instructions for installing the Xeus-Cling C++ Jupyter kernels in a CoCalc project.
The outline is:
Xeus-Cling provides kernels for Project Jupyter enabling the C++ programming language in the Jupyter notebook.
Due to a minor obstacle, Xeus-Cling is so far not installed system-wide in CoCalc. Solving that is tracked at CoCalc issue #2324. The transition to Ubuntu 18.04, planned for May-June 2018, will hopefully solve the issue.
However, it is possible to install Xeus-Cling manually in a CoCalc project, following the instructions below.
The solution we propose is to
The first step is to download Miniconda. by typing the following in a CoCalc terminal:
REMOTE='https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh' SCRIPT='Miniconda3.sh' curl -o $SCRIPT $REMOTE
Once the download is complete, we run the installation script by typing the following in our CoCalc terminal:
and then following the instructions that script gives, which will amount to:
Once that is done, we need to update our PATH, in one of two ways: close and re-open the terminal, or run this command in the terminal:
Run the following in the terminal
conda install xeus-cling -c QuantStack -c conda-forge
Optionally, you can also install xwidgets to enable Jupyter interactive widgets in the C++ kernel, by running:
conda install xwidgets -c QuantStack -c conda-forge
Note that this optional extra install will only work in the "Plain Jupyter" server, which you can launch by going to the CoCalc project's "settings" tab, and scrolling to the very bottom, and clicking "Plain Jupyter Server".
The last step of our installation is to make Jupyter aware of the new kernels, by installing them in the appropriate location.
For this, it suffices to run the following in our CoCalc terminal:
jupyter kernelspec install --user miniconda3/share/jupyter/kernels/xeus-cling-cpp11 jupyter kernelspec install --user miniconda3/share/jupyter/kernels/xeus-cling-cpp14
To test that everything went well, we open a Jupyter notebook worksheet in our CoCalc project.
Using the "Kernel > Change Kernel" menu item in the worksheet, we change to the "xeus C++11" kernel, which should appear towards the end of the list of available kernels.
If a "Not trusted" indication appears near the kernel name at the top right of the worksheet, click these words and change the setting to "Trusted".
In a code cell, type some C++11 code, for example:
int i = 1; i + 3
then evaluate the cell!
Thanks to QuantStack for developing the xeus-cling Jupyter kernels for C++11 and C++14!
Exploring this topic as well as writing and publishing this installation guide and example worksheet was facilitated by
CoCalc project upgrades (internet access, member hosting) for development, kindly provided by SageMath Inc.
financial support from OpenDreamKit, "Horizon 2020" "European Research Infrastructures" project #676541.
Thanks to Sylvain Corlay for making the installation one step simpler, after a first version of this document was published.