Skip to content

Cannot run it with Jupyter-lab #367

Open

Description

@sweinst

I've been successful in building it and running it with jupyter-lite but I was unsuccssfull running with jupyter-lanb
Is it possible to run it with jupyter-lab?

Activity

  1. mcbarton commented on Jul 16, 2025

    @mcbarton
    Collaborator

    @sweinst Yes it does work with Jupyter Lab. If you follow the instructions here https://github.com/compiler-research/xeus-cpp#installation-within-a-mamba-environment-non-wasm-build-instructions , then you should be able to try it out locally in Jupyter Lab. If you cannot get it working in Jupyter Lab locally, then you can try it out in Jupyter Lab using the binder link here https://github.com/compiler-research/xeus-cpp#trying-it-online (click on the image)

  2. sweinst commented on Jul 16, 2025

    @sweinst
    Author

    I've tried

    1. first to install it from the conda repository but the kernel crashed every time I was trying some basic code like
    #include <iostream>
    std::cout<<"Hello World!"<<std::endl;
    1. then I compiled it following the instructions
    • I've run a jupyter-lite instance as explained in the instructions. And it worked
    • In the same conda environment, I've installed jupyter-lab. The C++ kernel didn't appear. I've tried to tweak its configuration without success
    • I've created a new conda environment, installed jupyter-lite and xeus-cpp from conda, and it was working.
    • I've installed jupyter-lab and got the same crashes than in my first test
  3. mcbarton commented on Jul 16, 2025

    @mcbarton
    Collaborator

    You cannot install the jupyter lite (wasm) and jupyter lab (native) versions in the same environment. The xeus-cpp kernels are built for different platforms. You need to have them in separate environments like in the readme instructions.

  4. sweinst commented on Jul 18, 2025

    @sweinst
    Author

    I've found the issue: it seems that xeus-cpp has interaction issues with the jupyterlab extension: jupyterlab-mathjax3-web
    If I don't install it, it works

  5. anutosh491 commented on Jul 18, 2025

    @anutosh491
    Collaborator

    Hmm, hearing this for the first time. Do you have an error log or something that we can see ?

  6. anutosh491 commented on Aug 20, 2025

    @anutosh491
    Collaborator

    cc @sweinst

    Were you able to get past your error ?

  7. sweinst commented on Aug 20, 2025

    @sweinst
    Author

    Almost.
    I've tried many things and finally I've built gcc-15.1.0 and set it as the default compiler (as I needed a more comprehensive implementation of C++23). I've also reverted to the conda version.

    It worked fine at the exception of the output streams. It was the initial issue I had. Every time I use for example "std::cout", it crashes.

    I've replaced the streams by "std::print" & co. And now it's working.

  8. anutosh491 commented on Aug 21, 2025

    @anutosh491
    Collaborator

    Would you like to educate us with your use case ? Probably we might be able to assist you better !

    cc @sweinst

  9. sweinst commented on Aug 21, 2025

    @sweinst
    Author

    Sure.

    First my configuration:

    • Ubutbu 25.04 (I had the same problem with 24.04 and 24.10)
    • gcc 15.1.0 (I've built it and set it as the default C/C++ compliler)
    • clang 20.1.8 installed from the LLVM repository
    • python 3.12.11 from an environment created by conda/mamba
    • jupyterlab and xeus-cpp installed by conda-mamba
    s> mamba list jup*
    List of packages in environment: "/home/serge/mamba/envs/jupyterlab"
    
      Name                           Version  Build         Channel
    ─────────────────────────────────────────────────────────────────────
      jupyter                        1.1.1    pyhd8ed1ab_1  conda-forge
      jupyter-lsp                    2.2.6    pyhe01879c_0  conda-forge
      jupyter_client                 8.6.3    pyhd8ed1ab_1  conda-forge
      jupyter_console                6.6.3    pyhd8ed1ab_1  conda-forge
      jupyter_core                   5.8.1    pyh31011fe_0  conda-forge
      jupyter_events                 0.12.0   pyh29332c3_0  conda-forge
      jupyter_server                 2.16.0   pyhe01879c_0  conda-forge
      jupyter_server_terminals       0.5.3    pyhd8ed1ab_1  conda-forge
      jupyterlab                     4.4.5    pyhd8ed1ab_0  conda-forge
      jupyterlab-mathjax3-web        0.1.1    pypi_0        pypi
      jupyterlab-spellchecker        0.8.4    pyhd8ed1ab_0  conda-forge
      jupyterlab-spreadsheet-editor  0.7.2    pyhd8ed1ab_1  conda-forge
      jupyterlab_pygments            0.3.0    pyhd8ed1ab_2  conda-forge
      jupyterlab_server              2.27.3   pyhd8ed1ab_1  conda-forge
      jupyterlab_widgets             3.0.15   pyhd8ed1ab_0  conda-forg
    
    > mamba list xeus*
    List of packages in environment: "/home/serge/mamba/envs/jupyterlab"
    
      Name      Version  Build       Channel
    ──────────────────────────────────────────────
      xeus      5.2.3    hf4f7e68_0  conda-forge
      xeus-cpp  0.7.1    h11be711_0  conda-forge
      xeus-zmq  3.1.0    hbb7c33c_2  conda-forge
    • I've installed jupyterlab as a service. When I start a c++ kernel, I get the logs
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: clang version 20.1.7 (https://github.com/conda-forge/clangdev-feedstock add947ae7a0ef5f571eba24c5d9ebb35c6f4ae53)
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Target: x86_64-conda-linux-gnu
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Thread model: posix
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: InstalledDir: /home/serge/mamba/envs/jupyterlab/bin
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/13
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/14
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/15
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/15
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Candidate multilib: .;@m64
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Candidate multilib: 32;@m32
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Candidate multilib: x32;@mx32
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: Selected multilib: .;@m64
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  "/home/serge/mamba/envs/jupyterlab/bin/xcpp" -cc1 -triple x86_64-conda-linux-gnu -E -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name "<<< inputs >>>" -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb "-fdebug-compilation-dir=/home/serge/notebooks/c++/error handling" -v "-fcoverage-compilation-dir=/home/serge/notebooks/c++/error handling" -resource-dir /home/serge/mamba/envs/jupyterlab/lib/clang/20 -isystem /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0 -isystem /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0/x86_64-pc-linux-gnu -isystem /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0/backward -isystem /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/include -isystem /usr/local/include -isystem /opt/gcc-15/include -isystem /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/include-fixed -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -I /home/serge/mamba/envs/jupyterlab/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++ -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/backward -internal-isystem /home/serge/mamba/envs/jupyterlab/lib/clang/20/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++23 -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fincremental-extensions -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o - -x c++ "<<< inputs >>>"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: clang -cc1 version 20.1.7 based upon LLVM 20.1.7 default target x86_64-conda-linux-gnu
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/x86_64-linux-gnu"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/backward"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring nonexistent directory "/home/serge/mamba/envs/jupyterlab/lib/clang/20/include"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring nonexistent directory "/include"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring duplicate directory "/usr/local/include"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: ignoring duplicate directory "/usr/include"
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: #include "..." search starts here:
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: #include <...> search starts here:
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /home/serge/mamba/envs/jupyterlab/include
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0/x86_64-pc-linux-gnu
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/../../../../include/c++/15.1.0/backward
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/include
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /usr/local/include
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/include
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /opt/gcc-15/lib/gcc/x86_64-pc-linux-gnu/15.1.0/include-fixed
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /usr/include/x86_64-linux-gnu
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /usr/include
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]:  /usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++
    Aug 21 07:17:43 Serge-Linux jupyter-lab[12856]: End of search list.
    

    When I try to run:

    #include <iostream>
    std::cout << "Hello World!" << std::endl;

    I get the error:

    Kernel Restarting
    The kernel for c++/error handling/Untitled.ipynb appears to have died. It will restart automatically.
    

    The jupyterlab logs only show that it has lost connection with the kernel.

    But

    #include <print>
    std::println("Hello World!");

    works fine!

  10. sweinst commented on Aug 21, 2025

    @sweinst
    Author

    BTW, at the exception of the iostreams, all the rest seem to work fine. I can run far more complex examples if I don't use iostreams

  11. sweinst commented on Sep 12, 2025

    @sweinst
    Author

    I've finally got a working version...

    The problem seemed to be with the "jupyterlab-mathjax3-web" extension

    I've read many times that JupyterLab was using MathJax version 2 and not the version 3. I needed the version 3 in order to be able to use LaTeX packages like physics. The other extension "jupyterlab-mathjax3" didn't seem to support Mathjax commands like "\require{physics}"

    After more digging, I've discovered that the latest version of JupyterLab is in fact using MathJax3.2 by default!

    So, I removed the extension and now I can use C++ iostreams!

    I think that all these extensions were the predecessors of the actual implementation and should not be used at all

  12. anutosh491 commented on Sep 12, 2025

    @anutosh491
    Collaborator

    Hmm, I haven't experienced this before. If you know the problem and have a working solution, maybe raise a Pr ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triageUsed in auto labelling of new issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions