跳转至内容

Jupyter

来自 ArchWiki

Jupyter 是一个项目,它提供了基于浏览器的交互式环境,用于编程、数学和数据科学。它通过插件(“内核”)支持多种语言,例如 PythonRubyHaskellRScalaJuliaKotlin

JupyterLab 是“Jupyter 的下一代 Notebook 界面”,而 Jupyter Notebook 是原始版本。请参阅 Jupyter 网站以进行比较。

安装

要为当前用户安装第三方 Jupyter Notebook 扩展,请在执行 jupyter nbextension install 时使用 --user 选项。要为JupyterLab 扩展的安装执行相同的操作,请设置以下环境变量

JUPYTERLAB_DIR=$HOME/.local/share/jupyter/lab

并通过运行 jupyter lab paths 进行验证。然后继续按照常规安装说明进行操作。

运行

要启动 JupyterLab,请运行

$ jupyter lab

要启动 Jupyter Notebook,请运行

$ jupyter notebook

如果未自动打开 Web 浏览器,请导航到标准输出中显示的 URL。

要启动 JupyterLab 而不启动浏览器并在端口 9999 上监听,请运行

$ jupyter lab --no-browser --port 9999

要更改默认行为,请编辑配置文件

~/.jupyter/jupyter_lab_config.py
c = get_config()
c.ExtensionApp.open_browser = False
c.ServerApp.port = 9999

有关所有选项的概述,请参见 jupyter lab --help-all,或者运行 jupyter lab --generate-config 来生成默认配置文件。

内核 (Kernels)

C++

安装 cling-jupyter-gitAUR 包。

Haskell

安装 ihaskell 包。然后运行 ihaskell install

Julia

安装 julia 包并运行 julia 进入 REPL 提示符。然后运行

using Pkg
Pkg.add("IJulia")

有关包管理的更多详细信息,请参阅 Julia 手册

Python

Python 3 内核通过 python-ipykernel 默认使用。

Perl

安装 iperlAUR 包并运行 iperl。然后按 Ctrl+d。现在如果您运行 jupyter,您将看到 perl。

R

安装 r-irkernelAUR 包。然后在一个 R 控制台中运行

require(IRkernel)
IRkernel::installspec()

或者,您可以按照 IR Kernel 中的 安装说明进行操作。

Rust

安装 evcxr_jupyterAUR 包。

SageMath

安装 sagemath 包。

Octave

安装 jupyter-octave_kernelAUR 包。

Maxima

安装 maxima-jupyter-gitAUR 包。

Cadabra

安装 cadabra2AUR 包。

Kotlin

安装 python-kotlin-jupyter-kernelAUR 包。

JupyterLab 中的交互式小部件

本文或本章节的准确性存在争议。

原因: 链接的问题特定于 python-matplotlib,本节的标题过于笼统。链接的评论建议使用 %matplotlib ipympl,而下面的说明包含 %matplotlib widget。最好链接到 matplotlib 的 magic 命令的正确文档。(在 Talk:Jupyter 中讨论)

为了在 Jupyter Lab 中启用交互式小部件,请按照此 GitHub 问题的说明安装 python-ipympljupyterlab-widgets。之后,在您的 notebook 中使用

%matplotlib widget

安装扩展后,别忘了重启您的 JupyterLab 实例。

在进行扩展操作后,也许还可以 右键单击 -> 清除所有单元格的输出 会有所帮助

参见

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.