jupyterlab的基本使用

jupyterlab官方文档

jupyterlab安装

pip install jupyterlab

这里仅介绍pip安装方式,其他安装方式请参考官方安装指导

jupyterlab运行

jupyter-lab

更改默认工作路径

jupyter lab --generate-config

根据提示生成的文件路径,找到并打开文件,如我的是在~/.jupyter/中生成了jupyter_notebook_config.py文件

找到c.NotebookApp.notebook_dir并配置成想修改的默认路径即可

在虚拟环境中使用jupyterlab

进入虚拟环境,如我有个虚拟环境是3.8test
进入虚拟环境后执行python -m ipykernel install --user --name=virtualenvname

(3.8test) ~/Monkeyjerry # python -m ipykernel install --user --name=3.8test

如果提示No module named ipykernel,通过pip install ipykernel先安装下即可

启动服务后就可以在launcher中看到虚拟环境,然后就可以创建虚拟环境相关的notebook等

操作

切换到classic notebook

菜单栏 - help - launch classic notebook

开启行号显示

菜单栏 - view - show line numbers

常用快捷键(mac)

⌃↩:运行选中代码块
⇧↩: 运行代码块并选择下面的代码块
⌥↩: 运行代码块并且插入新的代码块
: 代码完成或缩进
dd: 删除选中单元格
z: 撤销删除
m: 代码块变成markdown
a: 在上面插入代码块
b: 在下面插入代码块

注意命令行模式和编辑模式
classic notebook略有不同,可在其菜单栏 - 帮助 - 快捷键中查看

云端jupyter