Clang-Repl kernel for Jupyter
A simple Jupyter kernel for C/C++ using Clang-Repl. It works on Windows and Linux. (MacOS is not tested)
See: Clang-Repl
Please use Python 3.11 or higher. (3.12 is recommended)
-
Windows 11 python3 3.12.0 Selected Jupyter core packages... IPython : 8.16.1 ipykernel : 6.25.2 ipywidgets : not installed jupyter_client : 8.4.0 jupyter_core : 5.4.0 jupyter_server : 2.7.3 jupyterlab : 4.0.7 nbclient : 0.8.0 nbconvert : 7.9.2 nbformat : 5.9.2 notebook : 7.0.5 qtconsole : not installed traitlets : 5.11.2
-
Ubuntu 22.04 python3 3.12 IPython : 8.16.1 ipykernel : 6.25.2 ipywidgets : not installed jupyter_client : 8.4.0 jupyter_core : 5.4.0 jupyter_server : 2.7.3 jupyterlab : 4.0.7 nbclient : 0.8.0 nbconvert : 7.9.2 nbformat : 5.9.2 notebook : 7.0.5 qtconsole : not installed traitlets : 5.11.2
See: How to Install Python 3.12 on Ubuntu 22.04 - LinuxTuto See: Setting the Default python to python3 | Baeldung on Linux
CAUTION
currently windows printf() not working. (It will be fixed soon). please use cout instead of printf().
Trouble shot
When you see
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
33 | #include <stddef.h>
| ^~~~~~~~~~
Segmentation fault
put path include 'stddef.h' file like and uninstall and reinstall clang-repl-kernel (You need to change llvm-18 to your llvm)
export CPLUS_INCLUDE_PATH=/usr/lib/llvm-18/lib/clang/18/include/
pip uninstall clang_repl_kernel
pip install clang_repl_kernel
When you see
ModuleNotFoundError: No module named 'ipykernel'
Use venv or conda environment and install notebook
python -m venv venv
source venv/bin/activate
pip install notebook
pip -r requirements.txt
From Pip to install
To install clang_repl_kernel from pip into the active Python environment
pip install clang_repl_kernel
From Git using Conda
To install clang_repl_kernel from git into a Conda environment
git clone https://github.com/ormastes/jupyter_kernels/clang_repl_kernel.git
cd clang_repl_kernel
conda create -n ker jupyter
conda activate ker
pip install .
Using the Clang-Repl kernel
Notebook: The File > New > Notebook menu in the notebook should show an Kernel Selection for the notebook. Select kernel ''Clang-Repl (C++xx)'' to start a new notebook. (XX is the version of C++ you want to use)
Console frontends: To use it with the console frontends, add --kernel clang_repl_cppXX to their command line arguments.
(XX is the version of C++ you want to use)
It fully checked on Windows 11 with clang 18.0.0, Python 3.11.5 and notebook 7.0.4. It fully checked on Ubuntu 20.04 with build_essential, clang 18.0.0, Python 3.10.22 and notebook 7.0.4.
Install default toolkit for cdoctest
run next command after install clang_repl_kernel
python -m clang_repl_kernel --install-default-toolchain
Reference
https://github.com/jupyter/echo_kernel https://saturncloud.io/blog/how-to-add-a-python-3-kernel-to-jupyter-ipython/ https://github.com/takluyver/bash_kernel
Metadata
Release files for clang-repl-kernel 1.6.27
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| clang_repl_kernel-1.6.27.tar.gz | 22.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| clang_repl_kernel-1.6.27-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 60.4 kB
Release files / clang_repl_kernel-1.6.27.tar.gz
| Download URL | clang_repl_kernel-1.6.27.tar.gz |
|---|---|
| Size | 22.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
afbcceb43f0057af479f3f1d92f826885152c547102391761e7f1220b3ca823f
|
|
BLAKE2b-256 checksum How to use checksums |
f586f4bf71c9dc292b14d62367a09c2c5fb9c52efe85cfc2d49d296057fffa3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|
Release files / clang_repl_kernel-1.6.27-py3-none-any.whl
| Download URL | clang_repl_kernel-1.6.27-py3-none-any.whl |
|---|---|
| Size | 37.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
065ae7abacde2af5b221cf91ba3818fdb27c8a5ad0aa70697320461eb4b362fd
|
|
BLAKE2b-256 checksum How to use checksums |
c7c3ed5776ef40fc74e624a7b54926a4aca2b99a0135e627e0fbd3792785eb50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.2
|