简介

Free software, open standards, and web services for interactive computing across all programming languages

JupyterLab: A Next-Generation Notebook Interface

JupyterLab is the latest web-based interactive development environment for notebooks, code, and data. Its flexible interface allows users to configure and arrange workflows in data science, scientific computing, computational journalism, and machine learning. A modular design invites extensions to expand and enrich functionality.

Jupyter Notebook: The Classic Notebook Interface

The Jupyter Notebook is the original web application for creating and sharing computational documents. It offers a simple, streamlined, document-centric experience.

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 安装基础包
yum install -y gcc python3

# 创建数据目录
mkdir /usr/local/jupyter

# 安装Jupyter
pip3 install --upgrade pip
pip3 install jupyter jupyterlab

# 运行Jupyter Lab
jupyter lab --ip 0.0.0.0 --allow-root --notebook-dir=/usr/local/jupyter

# 运行Jupyter Notebook
jupyter notebook --ip 0.0.0.0 --allow-root --notebook-dir=/usr/local/jupyter

# 查看访问信息
jupyter lab list

# 配置systemctl
cat > /usr/lib/systemd/system/jupyter.service << EOF
[Unit]
Description=Jupyter Service
After=network.target

[Service]
User=root
Group=root
KillMode=mixed
Restart=always

ExecStart=/usr/local/bin/jupyter lab --ip 0.0.0.0 --allow-root --notebook-dir=/usr/local/jupyter

[Install]
WantedBy=multi-user.target
EOF

使用

Web访问地址:http://<ip>:8888/?token=<token>,点击Python即可开始编写。测试代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl

th = np.linspace(0, 2*np.pi, 128)


def demo(sty):
mpl.style.use(sty)
fig, ax = plt.subplots(figsize=(3, 3))

ax.set_title('style: {!r}'.format(sty), color='C0')

ax.plot(th, np.cos(th), 'C1', label='C1')
ax.plot(th, np.sin(th), 'C2', label='C2')
ax.legend()

demo('seaborn')

演示1

参考文档