# jupyter_kernel **Repository Path**: cloud_hydro/jupyter_kernel ## Basic Information - **Project Name**: jupyter_kernel - **Description**: 介绍在jupyter中运行C++/C程序的方法 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-12-04 - **Last Updated**: 2024-12-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 黑魔法,在jupyter中运行C++/C程序 `Jupyter Notebook`是一种基于`Web`的交互式计算环境,允许用户创建和共享包含实时代码、方程、可视化和叙述性文本的文档。 一般常用来做`Python`程序的调试,可以让用户保存中间变量的值,对于`debug`过程或展示结果非常友好,是一个很实用趁手的工具。 同时,`Python`相较于`C++/C`运行起来更加方便,不需要手动编译,在`jupyter`中一键即可运行。 `github`上提供了一个[仓库](https://github.com/QuantStack/xeus-cling),可以实现在`jupyter`中运行`C++/C`程序,从而让用户写`C++/C`程序像写`Python`一样简单 ## 环境要求 目前,只支持`Linux/Mac`,暂不支持`Windows`系统 需要先安装好`Anaconda`,并创建好相应的环境 ## C++ 安装方法: `conda install xeus-cling -c conda-forge` 检查内核: `jupyter kernelspec list` 输出: > Available kernels: > python3 /xxx/jupyter/kernels/python3 > xcpp11 /xxx/jupyter/kernels/xcpp11 > xcpp14 /xxx/jupyter/kernels/xcpp14 > xcpp17 /xxx/jupyter/kernels/xcpp17 可以看到,内核中除了`python3 `,还多了`xcpp*`,我们就可以用此内核执行`C++`程序 启动`jupyter notebook`,在右上角处切换内核,即可运行`C++`程序了,以下是示例结果 ![示例输出](./cpp1.png) ![示例输出](./cpp2.png) 可见,这里成功的导入了标准库、模块化程序以及输入输出。 ## C 同理,也可以安装适用于`C`的内核 `pip install jupyter-c-kernel`