【问题标题】:What is the difference between `jupyter notebook` and `jupyter server`?`jupyter notebook`和`jupyter server`有什么区别?
【发布时间】:2021-08-20 03:24:43
【问题描述】:

运行jupyter notebook 和jupyter server 给我的结果非常相似,描述也非常相似。

❯ jupyter notebook -h
The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.

❯ jupyter server -h
The Jupyter Server.

This launches a Tornado-based Jupyter Server.

server 没有加载 nbextensions 之类的差异,但我不明白为什么有两个命令有这么多重叠。

供参考,这是各个模块的版本。

❯ jupyter --version
jupyter core     : 4.7.1
jupyter-notebook : 6.3.0
qtconsole        : 5.0.3
ipython          : 7.22.0
ipykernel        : 5.3.4
jupyter client   : 6.1.12
jupyter lab      : 3.0.11
nbconvert        : 6.0.7
ipywidgets       : 7.6.3
nbformat         : 5.1.3
traitlets        : 5.0.5

【问题讨论】:

    标签: jupyter-notebook jupyter


    【解决方案1】:

    Jupyter Notebook(notebook 模块)包含两者:

    • 笔记本服务器(Web 应用程序的后端,托管笔记本内容,代理与内核的交互,并通过例如在启动时打开 Internet 浏览器与操作系统交互;这部分通常用 Python 编写),以及
    • 客户端(Web 应用程序的前端,例如 HTML 代码、javascript 和服务器上的一些额外 REST API 点)。

    但是,因为现在有多个客户端(前端)为笔记本提供不同的 Web 应用程序:

    • Jupyter 笔记本
    • JupyterLab
    • RetroLab
    • ntreact
    • 在 Jupyter 项目之外开发的多个专有客户端

    拆分所有这些使用的服务器组件是有意义的,例如JupyterLab 不必依赖 notebook。这也意味着如果需要对服务器组件进行修复,它可以独立于 Jupyter Notebook 发布周期快速发布(并且所有前端的用户都可以立即受益)。

    因此,为了让拆分更干净,旧的 Jupyter Notebook 被拆分为:

    • jupyter-server - 由 JuptyterLab、RetroLab、ntreact 改编的服务器
    • nbclassic - Jupyter Notebook 作为 jupyter-server 扩展

    这意味着用户和开发人员的变化,一些已经在"migrate from notebook" 文档中描述:

    • 特定于服务器而非笔记本的选项已从 c.NotebookApp 重命名为 c.ServerApp(特定于笔记本的选项仍为 c.NotebookApp)
    • 服务器特定的配置现在存储在jupyter_server_config.py 而不是jupyter_notebook_config.py(.json 版本相同)
    • 用户现在应该使用jupyter server extension 而不是jupyter serverextension(注意多余的空格!)来列出、启用或禁用扩展程序
    • 服务器扩展需要将它们的文件放在一个新的位置:etc/jupyter/jupyter_server_config.d 而不是etc/jupyter/jupyter_notebook_config.d(实际上大多数更新为支持 jupyter 服务器的扩展现在都将文件放置在这两个位置以向后兼容笔记本,但是这将在未来改变)

    请务必注意,根据您启动 jupyter notebook 的方式,您将看到正在使用的不同服务器:

    • jupyter nbclassic(假设已安装 nbclassic)将使用新的 jupyter-server
    • jupyter notebook 将使用旧的 notebook 服务器
    • jupyter lab 将从 JupyterLab 3.0 开始使用新的 jupyter-server,除非在 JupyterHub/Binder 上运行,它可能仍在使用旧的 notebook 服务器,具体取决于配置

    这也意味着您在运行 jupyter notebook 与 jupyter nbclassic 时可能会看到不同的扩展(取决于他们的开发人员是否更新了位置,以及他们是否决定要支持旧的 notebook 服务器)。

    创建nbclassic 替换而不是从现有notebook 包中删除服务器代码是为了确保向后兼容性,这就是为什么您仍然有两个Tornado 服务器副本(一个由jupyter notebook 提供)和一个jupyter server)。为了使情况更简单,您可以删除 notebook 并安装 nblcassic,但鉴于过渡正在进行中,您可能需要手动调整一些内容。但是,这只是暂时的情况,因为计划从 v7.0 开始将 Notebook 迁移为使用 jupyter server。

    这现在可能看起来不方便,但此步骤可确保核心 Jupyter 基础架构在未来具有更高的可维护性,并将在以后极大地使用户和系统管理员受益。

    【讨论】:

    • 感谢您的超级详细解答!
    • 很好的解释!这里最大的问题是,我们如何知道哪些配置现在进入 jupyter_server_config.py 以及哪些配置保存在 jupyter_notebook_config.py 中?我试过jupyter server --generate-config 和jupyter notebook --generate-config 但那里有很多重叠。
    猜你喜欢
    • 2019-06-06
    • 2018-12-01
    • 1970-01-01
    • 2020-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多