笔记本7的新功能#

本文档描述了Notebook 7中最初在相关Jupyter增强建议书中提到的新功能 [JEP 79] [jep 79] 。

调试器#

Notebook 7包括一个新的调试器,它允许您逐个单元格地调试代码。您还可以设置断点和检查变量。

好了! [a screenshot of the debugger] (https://user-images.githubusercontent.com/591645/195543524-e16647a1-a4e0-4832-929d-73d5a77ef001.png)

实时协作#

Notebook 7允许使用实时协作扩展,因此您可以与其他用户共享您的笔记本并对其进行实时编辑。

实时协作功能与JupyterLab中的相同,并作为JupyterLab的扩展提供。默认情况下未启用,但您可以使用安装 pip

pip install jupyter-collaboration

或与 conda

conda install -c conda-forge jupyter-collaboration

安装扩展后,重新启动Jupyter服务器,以便可以加载扩展。

备注

两个用户可以使用Notebook 7或JupyterLab在同一笔记本上工作。

好了! [a screencast showing how users can collaborate on the same document with both Notebook 7 and JupyterLab] (https://user-images.githubusercontent.com/591645/229854102-6eed73f4-587f-406e-8ed1-347b788da9ee.gif)

目录表#

Notebook 7包括一个新的目录扩展,允许您使用侧边栏在笔记本中导航。目录是内置的,默认情况下启用,就像在JupyterLab中一样。

好了! [a screenshot of the table of contents] (https://user-images.githubusercontent.com/591645/195544813-22e7dec9-846f-4aaa-913a-36a9ed908036.png)

主题化和黑暗模式#

默认情况下,Jupyter笔记本中提供了黑暗主题。您还可以安装其他主题作为JupyterLab扩展。

好了! [a screenshot of the dark theme] (https://user-images.githubusercontent.com/591645/229732821-3ab15024-e6d7-414d-94ca-246619da4b67.png)

您还可以安装许多其他的JupyterLab主题。例如,要安装 [JupyterLab Night] (https://github.com/martinRenou/jupyterlab-night)主题:

pip install jupyterlab-night

然后刷新页面并在设置中选择新主题:

好了! [a screenshot of a custom theme] (https://user-images.githubusercontent.com/591645/229733418-db0898b3-7e8c-4db5-98d6-2e9f813ab9e9.png)

国际化#

笔记本7现在提供了设置用户界面的显示语言的功能。

用户需要将该语言包作为单独的Python包进行安装。语言包分组在 [language packs repository on GitHub] (https://github.com/jupyterlab/language-packs/),,并可与安装 pip 。例如,可以使用以下命令安装法语(法国)语言包:

pip install jupyterlab-language-pack-fr-FR

安装语言包后,重新加载页面,新语言应在设置中可用。

好了! [a screencast showing how to switch the display language in Notebook 7] (https://user-images.githubusercontent.com/591645/229734057-e08a2020-58c1-4aa5-b30e-ebb83fcde12c.gif)

备注

Notebook 7和JupyterLab共享相同的语言包,因此可以在两个应用程序中使用相同的语言包。

可访问性改进#

Jupyter Notebook(CodeMirror 5)背后的文本编辑器存在严重的可访问性问题。幸运的是,随着JupyterLab升级到使用CodeMirror 6,这一可访问性瓶颈已经被解除,CodeMirror 6是对文本编辑器的完全重写,重点是可访问性。虽然这次升级需要大量的代码库修改,但JupyterLab 4也提供了这些更改。通过构建在JupyterLab之上,Jupyter Notebook 7直接受益于CodeMirror 6的升级。

支持多个JupyterLab扩展#

Notebook 7基于JupyterLab,因此支持许多现有的JupyterLab扩展。

您可以使用以下命令安装JupyterLab扩展 pipconda 。例如,要安装LSP(语言服务器协议)扩展以增强代码完成功能,可以使用以下命令:

pip install jupyter-lsp
conda install -c conda-forge jupyter-lsp

流行的扩展名,如 nbgraderRISE 已经移植到Notebook 7上。

Nbgrader#

备注

Nbgrader扩展仍在积极开发中,在PyPI上还没有与Notebook 7兼容的版本。然而,在Notebook 7最终发布之前,将会有与Notebook 7兼容的版本。

好了! [a screenshot showing the nbgrader extension in Notebook 7] (https://user-images.githubusercontent.com/32258950/196110653-6556c8d7-b169-4586-b1a1-66b3be05c790.png)

好了! [a second screenshot showing the nbgrader extension in Notebook 7] (https://user-images.githubusercontent.com/32258950/196110825-7e3b9237-1064-42be-a629-15a5510a3aee.png)

RISE#

警告

Rise扩展仍在积极开发中,目前还没有与Notebook 7兼容的版本。

Rise扩展是JupyterLab的另一个广受欢迎的扩展,正在移植到Notebook 7上。它可以让你的Jupyter笔记本变成幻灯片。

延期仍在进行中 [active development] (https://github.com/jupyterlab-contrib/rise).)准备好后,可以使用进行安装 pip

pip install jupyterlab-rise

以文档为中心的用户体验#

尽管有所有新功能,但如 [JEP 79] [jep 79] ,Notebook 7保持了经典笔记本以文档为中心的用户体验:

Jupyter Notebook应用程序提供以文档为中心的用户体验。也就是说,在Notebook应用程序中,包含文件管理器、运行工具选项卡和几个可选附加组件的登录页面是打开独立的单个文档的起点。这种以文档为中心的体验对许多用户来说很重要,这也是本提案旨在保留的第一个关键点。NoteBook V7将基于与V6不同的JavaScript实现,但它将保留以文档为中心的体验,其中每个单独的笔记本在单独的浏览器选项卡中打开,可见的工具和菜单集中在打开的文档上。

移动设备上的紧凑视图#

Notebook 7在移动设备上自动切换到更紧凑的布局,让您可以方便地在旅途中运行代码。

好了! [a screenshot of the compact view on mobile devices] (https://user-images.githubusercontent.com/591645/101995448-2793f380-3cca-11eb-8971-067dd068ccbe.gif)

参考文献#

这只是对Notebook 7新功能的快速概述。有关更多详细信息,您可以查看以下资源:

  • 这个 [JupyterLab Documentation] (https://jupyterlab.readthedocs.io/en/latest/)是了解更多关于JupyterLab和可用的扩展的很好的资源。由于Notebook 7基于JupyterLab,因此JupyterLab的许多可用功能和扩展也适用于Notebook 7。

  • [Migration Guide] (./Migrate_to_Notebook7.md),它解释了如何从经典笔记本迁移到笔记本7。