Jupyter 简明教程

Using github and nbviewer

Sharing Jupyter notebook – Using github and nbviewer

Sharing Jupyter notebook – Using github and nbviewer

当一个 GitHub 仓库中的 Jupyter Notebook 文件带有 .ipynb 扩展名时,当它们被打开时,它们将被渲染成静态 HTML 文件。笔记本的交互特性,诸如自定义的 JavaScript 绘图,将无法在你 GitHub 中的仓库中工作。

Jupyter Notebook files with .ipynb extension in a GitHub repository will be rendered as static HTML files when they are opened. The interactive features of the notebook, such as custom JavaScript plots, will not work in your repository on GitHub.

要使用 GitHub 共享笔记本文件,请登录到 https://github.com ,创建一个公共仓库。然后使用文件上传按钮上传你的文件,如下所示:

To share notebook file using github, login to https://github.comand create a public repository. Then upload your files using upload file button as shown below −

github

这会给你一个选择来提交对仓库所做更改的机会。然后,仓库会显示如下上传的文件:

This will give you an option to commit the changes made to the repository. Then, the repository will show uploaded file as below −

updated repository

点击上传的文件在 GitHub 查看器中查看。你可以把高亮的网址分享给别人。

Click on the uploaded file to view inside github viewer. You can share the highlighted URL to others.

inside github viewer

查看笔记本文件的另一种方法是使用 Project Jupyter 的 nbviewer 工具。打开 https://nbviewer.jupyter.org/ ,把你的仓库的文件 URL 放到文本框中,如所示。按下 Go 按钮查看笔记本。

Another way to view the notebook file online is by using nbviewer utility of Project Jupyter. Open https://nbviewer.jupyter.org/ and put URL of file in your repository in the textfield as shown. Press Go button to view the notebook.

nbviewer

这两种方法都会把笔记本文件显示为静态 HTML。为了能够在笔记本中执行代码,使用 Jupyter 项目的 Binder 应用程序打开它。

Both these methods display notebook file as static html. To be able to execute code in the notebook, open it using Binder application of Jupyter project.

binder application

在 nbviewer 窗口中,你会看到 “在 Binder 中执行” 按钮。点击它,你会看到笔记本文件被打开,就像你从本地机器中笔记本服务器的本地仪表盘打开它一样。你可以执行诸如添加/编辑单元格、运行单元格等所有操作。

In the nbviewer window you will see ‘Execute on Binder’ button. Click on it and you will see the notebook file opened exactly like you open it from local dashboard of notebook server on your local machine. You can perform all actions like add/edit cells, run the cells etc.

execute on binder