Jupyter教程

官网:

https://jupyter.org/

https://jupyter.org/try 试试 Jupyter

https://docs.jupyter.org/en/latest/

https://docs.jupyter.org/en/latest/reference/ipython.html Jupyter 内核

子项目

https://docs.jupyter.org/en/latest/projects/content-projects.html

用法

https://docs.jupyter.org/en/latest/use/using.html

jupyter命令

https://docs.jupyter.org/en/latest/use/jupyter-command.html

命令 jupyter notebook 会启动 Jupyter 应用程序。jupyter 命令主要是一个子命令命名空间。例如,如果 PATH 环境变量中包含 jupyter-foo,则该命令会以子命令 jupyter foo 的形式运行。

除了启动 Jupyter 应用程序之外,jupyter 命令还可以用于执行其他操作。

1
2
3
4
5
6
7
8
9
10
11
12
# 显示帮助信息,包括可用的子命令。
jupyter -h

options:
-h, --help
--version 显示 Jupyter 核心包的版本
--config-dir 显示 Jupyter 配置目录
--data-dir 显示 Jupyter 数据目录
--runtime-dir 显示 Jupyter 运行时目录
--paths 显示所有 Jupyter 路径。添加 --json 可转换为机器可读格式。
--json 以机器可读的 JSON 格式输出路径
--debug 输出路径的调试信息

常用目录和文件位置

https://docs.jupyter.org/en/latest/use/jupyter-directories.html

Jupyter 将不同类型的文件(例如配置文件、数据文件、运行时文件)存储在多个不同的位置。可以通过设置环境变量来自定义每种文件类型的存储位置。

Jupyter 将数据文件(nbextensions、kernelspecs)与运行时文件(日志、pid 文件、连接文件)和配置文件(config 文件、custom.js)分开。

安装

所有(推荐)

1
2
3
# 将几个核心的 Jupyter 项目作为依赖项一次性安装到您的环境中。包括 notebook、jupyterlab、ipython、jupyter-console 等
pip install jupyter
pip install jupyter -i

JupyterLab

1
2
3
4
5
################ 安装
pip install jupyterlab

################ 运行
jupyter lab

Jupyter Notebook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
################ 安装
pip install notebook


################ 运行
# 执行命令的当前目录作为 Notebook 的根目录(服务器将在当前目录启动)
jupyter notebook
# 指定 Notebook 服务器的根目录(服务器将在指定目录启动)
jupyter notebook --notebook-dir=/data/local/workspaces/mars-python/
# 监听所有可用的网络接口,指定服务器运行的端口号,允许以 root 用户身份运行。
jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root


################ 子命令
# 用于设置或重置访问 Jupyter Notebook 服务器的密码,它会提示您输入并确认一个新密码,然后将加密后的密码存储在一个配置文件中
jupyter notebook password
# 列出当前用户在系统中所有正在运行的 Jupyter Notebook 服务器
jupyter notebook list
# 尝试关闭所有正在运行的 Jupyter Notebook 服务器
jupyter notebook stop
# 关闭指定端口的服务器
jupyter notebook stop 8888