一、安裝anaconda
1、下載安裝腳本
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2019.10-Linux-x86_64.sh
Anaconda3-2019.10-Linux-x86_64.sh 可以在清華鏡像站找最新的版本替換。
2、運行安裝嚮導
bash Anaconda3-2019.10-Linux-x86_64.sh
安裝完成後reboot
3、重啓完成後確認是否安裝成功
conda --version
二、配置jupyter lab
-
進入python命令行模式,輸入以下命令:
from notebook.auth import passwd passwd()
輸入方便你記的密碼,連續輸;兩次..輸完密碼後,會輸出一個字符串,形如: ’sha1:9e7a5c5e0a29:8cbdvsv2344d141c92beab1c5bc6e9avsdvdsvsv’將其保存下來, 完成以上操作後,通過exit()推出ipython環境
-
進入到安裝目錄:cd /home/xxx/anaconda3/etc/jupyter, 執行 :
jupyter lab --generate-config
命令會產生配置文件:/home/xxx/.jupyter/jupyter_notebook_config.py
-
編輯配置文件
vi /home/xxx/.jupyter/jupyter_notebook_config.py 修改相關內容如下:c.NotebookApp.ip = '*' # 允許訪問此服務器的 IP,星號表示任意 IP c.NotebookApp.password = u'sha1:xxx:xxx' # 之前生成的密碼 hash 字串 c.NotebookApp.open_browser = False # 運行時不打開本機瀏覽器 c.NotebookApp.port = 8888 # 使用的端口,隨意設置 c.NotebookApp.enable_mathjax = True # 啓用 MathJax c.NotebookApp.allow_remote_access = True #允許遠程訪問 c.NotebookApp.notebook_dir = '/home/xxxx/notebook' 默認打開的工作目錄
- 打開防火牆
firewall-cmd --zone=public --add-port=8888/tcp --permanent firewall-cmd --query-port=8888/tcp firewall-cmd --reload
- 啓動服務
#前臺運行模式(命令行窗口不能關閉) jupyter lab #後臺運行模式 nohup jupyter lab &
- jupyter lab 安裝插件
- 安裝 node.js
conda install -c conda-forge nodejs
- 打開 Extension Manager (默認是關閉的)
三、給jupyter lab 安裝C++ kernel
- 安裝C++ kernel(xeus-cling)
創建新的虛擬環境,命名爲cling
,或者你喜歡的其他名稱conda create -n cling
- 切換到新創建的虛擬環境
conda activate cling
-
給新環境安裝
jupyter lab
conda install jupyterlab
-
使用
conda-forge
鏡像channel安裝xeus-cling
conda install xeus-cling -c conda-forge
-
檢查是否成功安裝了kernel
jupyter kernelspec list
-
正確安裝,會顯示以下四個kernel:
python3 /anaconda3/envs/cling/share/jupyter/kernels/python3 xcpp11 /anaconda3/envs/cling/share/jupyter/kernels/xcpp11 xcpp14 /anaconda3/envs/cling/share/jupyter/kernels/xcpp14 xcpp17 /anaconda3/envs/cling/share/jupyter/kernels/xcpp17
四 、給jupyter lab 安裝C kernel(jupyter-c-kernel)
- 安裝步驟跟安裝(C++ kernel)類似,直接按照以下步驟安裝
#如果沒有安裝gcc需要預先安裝,否則程序無法運行 $yum install gcc conda activate cling pip install jupyter-c-kernel install_c_kernel --user jupyter kernelspec list
c /home/heaven/.local/share/jupyter/kernels/c python3 /home/heaven/anaconda3/envs/cling/share/jupyter/kernels/python3 xcpp11 /home/heaven/anaconda3/envs/cling/share/jupyter/kernels/xcpp11 xcpp14 /home/heaven/anaconda3/envs/cling/share/jupyter/kernels/xcpp14 xcpp17 /home/heaven/anaconda3/envs/cling/share/jupyter/kernels/xcpp17
五、運行jupyter lab
conda activate cling
#前臺運行模式(命令行窗口不能關閉)
jupyter lab
#後臺運行模式
nohup jupyter lab &
參考文章:
https://blog.csdn.net/weixin_37543731/article/details/99254107