安装cpp内核

1. 安装前的准备

由于该内核编译时需要Python的import模块,而此模块在Python3中被移除,使用importlib.import替代,所以新建conda环境,设置Python=2.7

1
2
conda create -n lab python=2.7
conda activate lab

  安装Python-devel gcc cmake gcc-c++

1
yum install gcc gcc-c++ cmake python-devel

安装distro

1
conda install distro

下载源代码并编译c++库

1
python cpt.py --create-dev-env Release --with-workdir=./cling-build/

//此处软件作者使用Debug方式进行编译,但我发现此方式会出现memory exhausted错误

解决办法参考自stackoverflow.com Memory exhausted solution

2. 修改环境变量

1
export PATH=/cling-install-prefix/bin:$PATH

3. 安装cling内核

1
2
3
4
5
6
7
8
cd /cling-install-prefix/share/cling/Jupyter/kernel //此处cling-install-prefix文件夹修改为你安装cling准备工具时的src文件夹
conda activate jupyter
pip3 install -e.
jupyter kernelspec install --user cling-cpp11
jupyter kernelspec install --user cling-cpp14
jupyter kernelspec install --user cling-cpp17
jupyter kernelspec install --user cling-cpp1z
jupyter kernelspec list //显示已安装的内核

(非必须)Nginx反向代理设置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
server {
server\_name DOMAIN IP\_ADDRESS; # 服务器域名和 IP 地址
listen 80;
location / {
proxy\_pass http://127.0.0.1:JUPYTER\_PORT/; # JUPYTER\_PORT 为 Jupyter 运行端口
proxy\_set\_header X-Real-IP $remote\_addr;
proxy\_set\_header Host $host;
proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;
proxy\_http\_version 1.1;
proxy\_set\_header Upgrade $http\_upgrade;
proxy\_set\_header Connection "upgrade";
proxy\_redirect off;
}
}

解决方法来自知乎:https://www.zhihu.com/question/266589600/answer/312363000
jupyterlab的启动参考上一节文章:基于arm64架构的JupyterLab cpp环境安装(一)


安装方法参考自软件原作者github:https://github.com/root-project/cling
插图来自:Illustration by Freepik Stories