jupyter-xeus / xeus-cling

Jupyter kernel for the C++ programming language
BSD 3-Clause "New" or "Revised" License
3.08k stars 297 forks source link

%%python not working in xeus-cpp #517

Closed kshitijdshah99 closed 7 months ago

kshitijdshah99 commented 7 months ago

I have followed following commands in the linux terminal with the help of which I am able to run the jupyter-file locally and my C++ code runs properly in the cell but on writing %%python for running python code my code is not being run in a python cell.

Installation within a mamba envirnoment xeus-cpp has not been packaged for the mamba (or conda) package manager.

To ensure that the installation works, it is preferable to install xeus-cpp in a fresh environment. It is also needed to use a miniforge or miniconda installation because with the full anaconda you may have a conflict with the zeromq library which is already installed in the anaconda distribution.

First clone the repository, and move into that directory

git clone --depth=1 https://github.com/compiler-research/xeus-cpp.git cd ./xeus-cpp The safest usage of xeus-cpp is to build and install it within a clean environment named xeus-cpp. You can create and activate this environment with mamba by executing the following

mamba create -n "xeus-cpp" source activate "xeus-cpp" We will now install the dependencies needed to compile xeux-cpp from source within this environment by executing the following

mamba install notebook cmake cxx-compiler xeus-zmq nlohmann_json cppzmq xtl jupyterlab clangdev=16 cpp-argparse pugixml doctest -c conda-forge Now you can compile the kernel from the source by executing (replace $CONDA_PREFIX with a custom installation prefix if need be)

mkdir build && cd build cmake .. -D CMAKE_PREFIX_PATH=$CONDA_PREFIX -D CMAKE_INSTALL_PREFIX=$CONDA_PREFIX -D CMAKE_INSTALL_LIBDIR=lib make && make install

kshitijdshah99 commented 7 months ago

@nthiery pls help me with this

nthiery commented 7 months ago

@nthiery pls help me with this

Sorry, I am a heavy user of xeus-cpp, but I have not needed this feature myself and am not a developer, so don't know more than you.

kshitijdshah99 commented 7 months ago

@minrk @afshin @jtpio do you have any idea or good resource for reference to solve this

martinRenou commented 7 months ago

Thank you for opening an issue. Please note that pinging many jupyter developers will not especially be useful for you, as not many of them would be working on xeus-cling or xeus-cpp. It's also adding noise to jupyter developer's notifications which is not always welcome.

I have followed following commands in the linux terminal with the help of which I am able to run the jupyter-file locally and my C++ code runs properly in the cell but on writing %%python for running python code my code is not being run in a python cell.

I think this is expected behavior. When using xeus-cpp or xeus-cling, you're executing C++ code, not Python code. The C++ kernel is not designed to execute Python code whatsoever.

What are you trying to achieve exactly? If you are willing to use both Python and C++ in the same notebook, I'd recommend looking into a tool like https://github.com/vatlab/jupyterlab-sos