❚ 前言

Jupyter LabJupyter 主打的最新数据科学生产工具,是基于Web的交互式开发环境。某种意义上,它的出现是为了取代 Jupyter Notebook,但它也包含了 Jupyter Notebook 的所有功能,非常方便研究和教学。 Jupyter Lab 的用途非常灵活,可支持数据清理和转换、统计建模、数据科学、科学计算和机器学习领域的广泛工作。

❚ 安装 Jupyter Lab

1. 云服务器环境

▸ CPU:2核   内存:2GB
▸ 系统盘:40GB SSD云硬盘
▸ 操作系统:Ubuntu Server 20.04 LTS 64bit
▸ Python版本: 3.9.13   pip版本:22.1.2
❚ 注:安装 Jupyter Lab 前需要安装Python(3.3版本及以上,或2.7版本)和pip

2. 安装 Miniconda

❚ 更新升级已安装的软件包至最新版本

su       // 切换到 root 用户
apt update && apt upgrade

❚ 以下操作不推荐使用 root 用户

su ubuntu    // 切换到 ubuntu 用户
cd          // 切换到 /home/ubuntu/

❚ 安装 Miniconda(清华源)

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
source ~/.bashrc
conda --v

❚ 切换 conda 源为清华源(可选)

 vim ~/.condarc

condarc 文件中添加以下内容

channels:- defaultsshow_channel_urls: truechannel_alias: https://mirrors.tuna.tsinghua.edu.cn/anacondadefault_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmsys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudbioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudmenpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudsimpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

❚ 清除索引缓存

conda clean -i

3. 安装 Jupyter Lab

conda install jupyterlab

❚ 准备 Jupyter Lab 密码

python   // 进入 Python 环境> from notebook.auth import passwd
> passwd()   # 输入自己想要设置的密码(重复)得到类似 'argon2:...'的加密串,保存备用
'argon2:$argon2id$v=19$m=10240,t=10,p=8$tuOUUSE/KyCKtjW6HmLLvg$WJWRe2O/TDJheuzPcWebZcXkSe8aoW8hsZQrKAyeGxQ'
> quit()     # 退出 Python 环境

4. 配置 Jupyter Lab 端口访问

jupyter lab --generate-config    // 创建配置文件
cd ~/.jupyter
vim jupyter_lab_config.py       // 编辑配置文件

根据自己需求更新以下内容

c.ServerApp.allow_origin = '*'    // 约 576 行
c.ServerApp.allow_remote_access = True // 约 614 行
c.ServerApp.ip = '0.0.0.0' // 默认是 localhost 约 775 行
c.ServerApp.notebook_dir = '/home/ubuntu/workspace' // 项目文件夹 约 868 行
c.ServerApp.password = 'xxxxxx' // 刚生成的类似 'argon2:...' 的加密串 约 887 行
c.ServerApp.open_browser = False // 禁止浏览器打开 约 876 行
c.ServerApp.port = 8080 // 端口 随自己选择即可 约 900 行

❚ 注:部署在云服务器需要检查是否在防火墙(安全组)开放你配置的端口

5. 运行 Jupyter Lab

jupyter lab

❚ 注:若选择 IP 直连,且已在防火墙开放对应端口,即可使用 IP:8888(端口) 访问

6. 开启插件管理器

conda install -c conda-forge jupyter_contrib_nbextensions

❚ 注:安装完成后再次运行 Jupyter Lab 将会有 GUI,此处不再赘述

7. 设置中文(简体)语言

pip install jupyterlab-language-pack-zh-CN

❚ 注:安装完成后再次运行 Jupyter Lab 需要在菜单栏选择 【设置】→ 【语言】→ 【中文(简体,中国)】 ,将会自动重载页面,配置完成!

8. 安装 Nodejs(安装插件需要)

conda install -c conda-forge/label/cf202003 nodejs

9. 添加 Julia 编程语言(可选)

❚ 获取 Julia 编程语言压缩包并解压

wget https://mirrors.tuna.tsinghua.edu.cn/julia-releases/bin/linux/x64/1.8/julia-1.8-latest-linux-x86_64.tar.gz
tar -xzvf julia-1.8-latest-linux-x86_64.tar.gz

❚ 配置 Julia 环境

vim ~/.bashrc

在文件末尾添加以下内容

export PATH=$PATH:/home/ubuntu/julia-1.8.0-rc4/bin // 添加环境变量
export JULIA_PKG_SERVER=https://mirrors.tuna.tsinghua.edu.cn/julia // 添加清华源为 Julia 包源

❚ 立刻加载更新后的设置,使之生效

source ~/.bashrc

❚ 配置 Jupyter 内核

julia    // 进入 Julia 环境julia> using Pkg
julia> Pkg.add("IJulia")
julia> exit()    // 退出 Julia 环境

10. 配置 C/C++ 内核(可选)

❚ 安装 C++ 内核

mamba install xeus-cling -c conda-forge

❚ 安装 C 内核

pip install jupyter-c-kernel
install_c_kernel --user

11. 安装 Python 数据科学/机器学习常用库

conda install pytorch torchvision torchaudio cpuonly -c pytorch
pip install numpy conda pandas scipy matplotlib
pip install joblib
pip install -U scikit-learn
pip install simplejson
pip install networks networkx
pip install opencv-python
pip install opencv-contrib-python opencv-python-headless
pip install Seaborn
pip install Keras

12. 配置 Jupyter Lab 开机自启动(方法1 可选)

❚ 新建 jupyter.service 文件并编辑

sudo vim /etc/systemd/system/jupyter.service

添加以下内容(以自己的配置为准)

[Unit]
Description=Jupyterlab
After=network.target
[Service]
Type=simple
ExecStart=/home/ubuntu/miniconda3/bin/jupyter-lab --config=/home/ubuntu/.jupyter/jupyter_lab_config.py --no-browser
User=ubuntu
Group=ubuntu
WorkingDirectory=/home/ubuntu/workspace
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target

❚ 设置开机自启动

sudo systemctl enable jupyter

❚ 其他相关控制命令

sudo systemctl start jupyter  (启动)
sudo systemctl stop jupyter  (停止)
sudo systemctl restart jupyter  (重启)

❚ 该方法存在启动后扩展管理器错误问题(如下所示):

与服务器扩展通信出错。请参考文档 以确保它已启用。
原因: Error: 500 (Internal Server Error)

❚ 注:该错误 仅对 插件管理器的网络连接有影响,不影响 Jupyter Lab 的正常使用!

13. 配置 Jupyter Lab 后台启动不挂断(方法2 可选)

❚ 新建 jupyter-start.sh 文件并编辑

vim jupyter-start.sh

添加以下内容(以自己的配置为准)

#!/bin/sh/bin/echo $(/bin/date +%F_%T) >> /home/ubuntu/startup.log
nohup /home/ubuntu/miniconda3/bin/jupyter-lab --allow-root > jupyter.log 2>&1 &ps -le | grep jupyterexit 0

❚ 启动 Jupyter Lab (关闭终端不挂断)

bash jupyter-start.sh

❚ 注:该方法尚 无法 实现服务器重启后自动运行,需要手动启动!

❚ 运行效果展示

❚ 注:本教程尚未讲解插件安装过程 ,以下为我已安装的插件,仅供参考!

Ubuntu20.04云服务器安装配置Jupyter Lab相关推荐

  1. Ubuntu20.04安装与配置记录

    Ubuntu20.04安装与配置记录 原文地址:Ubuntu20.04安装与配置记录 一.Ubuntu系统盘制作 1.1 Windows环境下制作系统盘 下载Ubuntu系统,选择桌面版. 下载工具系 ...

  2. 怎样安装python在桌面_在Windows上安装和配置 Jupyter Lab 作为桌面级应用程序教程...

    什么是 Jupyter Lab Jupyter Lab 是 Jupyter notebook 的升级版,优点这里不作赘述. 一.安装 Jupyter Lab 如果你安装了 Anaconda,最新版的 ...

  3. Ubuntu20.04 NAT 网络配置

    Ubuntu20.04 NAT 网络配置 背景 用 Vmware 安装好 Ubuntu 20.04 后发现网络用不了,也不能和宿主机互相 ping 通.通过下面的步骤可以实现设置静态 IP,使 Ubu ...

  4. 【一生一芯】Chap.1 “一生一芯”实验环境配置| VMware安装Ubuntu20.04 | PA工程配置 | 解决llvm版本问题

    [一生一芯]Chap.1 "一生一芯"实验环境配置| VMware安装Ubuntu20.04 | PA工程配置 | 解决llvm版本问题 0. 什么是PA? 1. 安装VMware ...

  5. Ubuntu20.04安装并配置SSH

    Ubuntu20.04上安装配置openssh-server 本文将介绍在Ubuntu20.04 Desktop上安装并配置使用openssh-server 1. 安装ssh sudo apt-get ...

  6. 阿里云服务器安装配置 python(CentOS 7.6)

    阿里云服务器安装配置 python(CentOS 7.6) 安装配置步骤 1.下载 2.解压编译安装 3.修改yum依赖 安装配置步骤 1.下载 ★ 创建目录,安装编译工具. 我这里最开始安装的是py ...

  7. DELF: DEep Local Features在Ubuntu20.04下安装配置

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 DELF: DEep Local Features在Ubuntu20.04下安装配置 一.安装Ubuntu20.04后配置深度学习环境 ...

  8. Ubuntu20.04 通过netplan 配置静态ip

    前言 ubuntu 从 17.10 开始,改成 netplan 方式配置,不在 /etc/network/interfaces 里固定 IP 的配置 ,配置写在 /etc/netplan/01-net ...

  9. ubuntu20.04系统安装及配置

    一.系统安装: 启动盘制作: 1.下载ubuntu20.04(ubuntu-20.04.1-desktop-amd64.iso):Ubuntu 20.04.2.0 LTS 2.用UltraISO制作U ...

最新文章

  1. python经典题库和答案_吐血总结,Python经典面试题及答案
  2. 新iPhone全面5G!4种杯型,最便宜只要5500,均内置中国北斗
  3. rand和srand
  4. boost::phoenix::val相关的测试程序
  5. superset数据集birth_names的负时间戳处理
  6. Jstorm+Spring+mybatis整合
  7. SkyEye仿真平台下的操作系统实验- 准备篇(一)
  8. [2013.8.16]小议innerText/HTML以及outerText/HTML
  9. 微商团队长的五条管理心法
  10. [译]C语言实现一个简易的Hash table(2)
  11. 2021-03-31【Caltech行人数据集的 .vbb 转 .xml 】(学习记录)
  12. java时间格式转换
  13. 华为od机考真题-平安果
  14. Python 爬取拉钩网工作岗位
  15. 游戏介绍——《逆转裁判》
  16. c++ string assign和operator=
  17. 前端面试题《CSS》
  18. 【MySQL】MySQL知识图谱
  19. excel 累加每个sheet中的值
  20. asp.net夜话之九:验证控件

热门文章

  1. javaEE版 oauth2 第三方登陆新浪微博
  2. Android google VR全景图导航
  3. 三菱FX系列PLC编程口通信协议总览
  4. Zotero 6.0 降级 5.x
  5. php函数不支持的功能有什么,wapl是什么功能?启用有什么用
  6. 微信小程序的底部菜单栏实现和界面顶部显示
  7. BMP24位照片格式
  8. 将汉语转换成拼音(全拼和缩写)
  9. elk搭建与简单的线上应用
  10. 追赶ChatGPT的难点与平替