jupyter lab 安装与远程使用(并配置C/C++ kernel)

本教程基于Centos 8 部署,先用sudo adduser xxx 创建一个新用户,jupyter在此账号下运行。

一、安装anaconda

1、在Linux服务器是新建议一个用户xxx,并切换到相应的用户  sudo xxx;

2、在/home/xxx/下载安装脚本 

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2020.07-Linux-x86_64.sh

Anaconda3-2020.07-Linux-x86_64.sh 可以在清华镜像站找最新的版本替换,清华大学开源软件镜像站https://mirrors.tuna.tsinghua.edu.cn。

3、运行安装向导

bash Anaconda3-2019.10-Linux-x86_64.sh

 安装完成后reboot

3、重启完成后确认是否安装成功

conda --version

二、配置jupyter lab

  1. 进入python命令行模式,输入以下命令:

    from notebook.auth import passwd
    passwd()

    输入方便你记的密码,连续输;两次..输完密码后,会输出一个字符串,形如: ’sha1:9e7a5c5e0a29:8cbdvsv2344d141c92beab1c5bc6e9avsdvdsvsv’将其保存下来, 完成以上操作后,通过exit()推出ipython环境

  2. 进入到安装目录:cd /home/xxx/anaconda3/etc/jupyter, 执行 :

    jupyter lab --generate-config

    命令会产生配置文件:/home/xxx/.jupyter/jupyter_notebook_config.py

  3. 编辑配置文件
    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' 默认打开的工作目录
    
  4. su root 打开防火墙
    firewall-cmd --zone=public --add-port=8888/tcp --permanent
    firewall-cmd --reload
    firewall-cmd --query-port=8888/tcp
     
  5. 启动服务
    #前台运行模式(命令行窗口不能关闭)
    jupyter lab
    #后台运行模式
    nohup jupyter lab &
    远程通过浏览器就可以访问jupyter lab了。
  6. jupyter lab 安装插件
  • 安装 node.js
    conda install nodejs
  • 打开 Extension Manager (默认是关闭的)

三、给jupyter lab 安装C++ kernel

  1. 安装C++ kernel(xeus-cling)
    创建新的虚拟环境,命名为cling,或者你喜欢的其他名称
    conda create -n cling
  2. 切换到新创建的虚拟环境
    conda activate cling

     

  3. 给新环境安装jupyter lab

    conda install jupyterlab

     

  4. 使用conda-forge镜像channel安装xeus-cling

    conda install xeus-cling -c conda-forge

     

  5. 检查是否成功安装了kernel
     

    jupyter kernelspec list

     

  6. 正确安装,会显示以下四个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)

  1. 安装步骤跟安装(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

  • 11
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装配置JupyterLab可以按照以下步骤进行: 1. 首先,从Docker中拉取Miniconda镜像,并从零开始安装。可以使用以下命令: ``` docker pull miniconda ``` 2. 激活Miniconda环境。可以使用以下命令: ``` source activate <环境名称> ``` 3. 使用pip安装JupyterLab。可以使用以下命令: ``` pip install jupyterlab ``` 4. 生成JupyterLab配置文件。可以使用以下命令: ``` jupyter lab --generate-config ``` 5. 将配置文件复制到指定位置。可以使用以下命令: ``` cp /home/admin555/.jupyter/jupyter_notebook_config.py /指定位置/jupyter_notebook_config.py ``` 6. 完成以上步骤后,您可以启动JupyterLab。可以使用以下命令: ``` jupyter lab ``` 请注意,根据您的操作系统和环境,配置文件的位置可能会有所不同。在Windows系统上,配置文件通常位于`C:\Users\用户名\.jupyter\jupyter_notebook_config.py`,而在Linux系统上,配置文件通常位于`/home/用户名/.jupyter/jupyter_notebook_config.py`。\[1\]\[2\]\[3\] #### 引用[.reference_title] - *1* [jupyter lab安装配置教程](https://blog.csdn.net/buluxianfeng/article/details/126149522)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Jupyter Lab安装配置、插件推荐、多用户使用教程](https://blog.csdn.net/qq_43701912/article/details/121446837)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值