jupyter notebook 安装 C/C++ kernel
如果你想在jupyter notebook中交互式编写C以及C++,那么本文是为你而写_
1. 准备工作
为了减少安装过程中不必要的烦恼,影响你美美的心情,请确保目标机器上已经安装了Anaconda,下载地址:https://www.anaconda.com/distribution/#download-section。如已安装,请跳过。
2. 安装环境
以下列举环境是经过实践检验的环境,仅供参考,并非要求严格一致。
2.1 Linux
- CentOS Linux release 7.4.1708 (Core)
- Anaconda3
- conda 4.6.11
2.2 macOS
- macOS Mojave 10.14.4
- Anaconda3
- conda 4.6.14
注:windows目前还未得到较好支持
3. 开始安装
C语言和C++由不同kernel支持,两者没有依赖关系,因此可以根据需要只安装其中一个,或两个都安装,但推荐安装C++ kernel,这是主流的kernel,由更加专业的团队维护的项目,C kernel是由个人开发者维护的小型项目,实现较为简单,但如果想快速体验在jupyter notebook运行C,也是不错的选择。如果想了解更多jupyter支持的kernel,可以参考https://github.com/jupyter/jupyter/wiki/Jupyter-kernels
3.1 安装C++ kernel (xeus-cling)
- 创建新的虚拟环境,命名为
cling
,或者你喜欢的其他名称,比如,如果你想在此环境安装C++和C Kernel,可以取名为c_cpp
conda create -n cling
- 切换到新创建的虚拟环境
conda activate cling
- 给新环境安装
jupyter
和notebook
conda install jupyter notebook
- 使用
conda-forge
镜像channel安装xeus-cling</