Python 如何与非程序员共享 Jupyter 笔记本?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31855794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 10:39:53  来源:igfitidea点击:

How can I share Jupyter notebooks with non-programmers?

pythonjupyter-notebookjupyter

提问by xav

I am trying to wrap my head around what I can/cannot do with Jupyter.

我正在努力思考我可以/不能用 Jupyter 做什么。

I have a Jupyter server running on our internal server, accessible via VPN and password protected.

我有一个 Jupyter 服务器在我们的内部服务器上运行,可通过 VPN 访问并受密码保护。

I am the only one actually creating notebooks but I would like to make some notebooks visible to other team members in a read-only way. Ideally I could just share a URL with them that they would bookmark for when they want to see the notebook with refreshed data.

我是唯一一个真正创建笔记本的人,但我想让其他团队成员以只读方式看到一些笔记本。理想情况下,我可以只与他们共享一个 URL,当他们想要查看带有刷新数据的笔记本时,他们会添加书签。

I saw export options but cannot find any mention of "publishing" or "making public" local live notebooks. Is this impossible? Is it maybe just a wrong way to think about how Jupyter should be used?

我看到了导出选项,但找不到任何提及“发布”或“公开”本地实时笔记本的内容。这是不可能的吗?考虑如何使用 Jupyter 可能只是一种错误的方式吗?

采纳答案by Michael Leonard

The "best" way to share a Jupyter notebook is to simply to place it on GitHub (and view it directly) or some other public link and use the Jupyter Notebook Viewer. When privacy is more of an issue then there are alternatives but it's certainly more complex; there's no built-in way to do this in Jupyter alone, but a couple of options are:

共享 Jupyter Notebook 的“最佳”方式是简单地将它放在 GitHub(并直接查看)或其他一些公共链接上,然后使用Jupyter Notebook Viewer。当隐私更成为一个问题时,还有其他选择,但它肯定更复杂;单独在 Jupyter 中没有内置的方法可以做到这一点,但有几个选择:

Host your own nbviewer

托管您自己的 nbviewer

GitHub and the Jupyter Notebook Veiwer both use the same tool to render .ipynbfiles into static HTML, this tool is nbviewer.

GitHub 和 Jupyter Notebook Veiwer 都使用相同的工具将.ipynb文件渲染为静态 HTML,这个工具是nbviewer

The installation instructions are more complex than I'm willing to go into here but if your company/team has a shared server that doesn't require password access then you could host the nbviewer on that server and direct it to load from your credentialed server. This will probably require some more advanced configuration than you're going to find in the docs.

安装说明比我愿意在这里介绍的要复杂,但是如果您的公司/团队有一个不需要密码访问的共享服务器,那么您可以在该服务器上托管 nbviewer 并引导它从您的凭据服务器加载. 这可能需要一些比您在文档中找到的更高级的配置。

Set up a deployment script

设置部署脚本

If you don't necessarily need liveupdating HTML then you could set up a script on your credentialed server that will simply use Jupyter's built-in export options to create the static HTML files and then send those to a more publicly accessible server.

如果您不一定需要实时更新 HTML,那么您可以在经过认证的服务器上设置一个脚本,该脚本将简单地使用 Jupyter 的内置导出选项来创建静态 HTML 文件,然后将它们发送到更可公开访问的服务器。

回答by Randy

Michael's suggestion of running your own nbviewer instance is a good one I used in the past with an Enterprise Github server.

Michael 关于运行您自己的 nbviewer 实例的建议是我过去在企业 Github 服务器上使用的一个很好的建议。

Another lightweight alternative is to have a cell at the end of your notebook that does a shell call to nbconvert so that it's automatically refreshed after running the whole thing:

另一个轻量级的替代方法是在你的笔记本末尾有一个单元格,它对 nbconvert 进行 shell 调用,以便在运行整个过程后自动刷新:

!ipython nbconvert <notebook name>.ipynb --to html

!ipython nbconvert <notebook name>.ipynb --to html

EDIT: With Jupyter/IPython's Big Split, you'll probably want to change this to !jupyter nbconvert <notebook name>.ipynb --to htmlnow.

编辑:使用 Jupyter/IPython 的 Big Split,您可能希望将其更改为!jupyter nbconvert <notebook name>.ipynb --to html现在。

回答by Anirudh

A great way of doing this on WordPress consists of the following steps:

在 WordPress 上执行此操作的一个好方法包括以下步骤:

Step 1:Open your Jupyter notebook in a text editor and copy the content which may look like so: Your .ipynb file may look like this when opened in a text editor

第 1 步:在文本编辑器中打开您的 Jupyter 笔记本并复制可能如下所示的内容: 您的 .ipynb 文件在文本编辑器中打开时可能如下所示

Step 2:Ctrl + Aand Ctrl + Cthis content. Then Ctrl + Vthis to a GitHub Gist that you should create.

第二步:Ctrl+ACtrl+C这个内容。然后按 Ctrl + V到您应该创建的 GitHub Gist。

Step 3:Create a public gist and embed the gist like you always embed gists on WordPress, viz., go to the HTML editor and add like so:

第 3 步:创建一个公共要点并像您总是在 WordPress 上嵌入要点一样嵌入该要点,即,转到 HTML 编辑器并像这样添加:

[gist gist_url]

I have actually implemented this on my blog. You can find the post here

我实际上已经在我的博客上实现了这一点。你可以在这里找到帖子

回答by guhur

It depends on what you are intending to do with your Notebook: do you want that the user can recompute the results or just playing with them?

这取决于您打算用 Notebook 做什么:您希望用户可以重新计算结果还是只是玩弄它们?

Static notebook

静态笔记本

NBVieweris a great tool. You can directly use it inside Jupyter. Github has also a render, so you can directly link your file (such as https://github.com/my-name/my-repo/blob/master/mynotebook.ipynb)

NBViewer是一个很棒的工具。您可以直接在Jupyter 中使用它。Github 也有渲染,所以你可以直接链接你的文件(比如https://github.com/my-name/my-repo/blob/master/mynotebook.ipynb

Alive notebook

活的笔记本

If you want your user to be able to recompute some parts, you can also use MyBinder. It takes some time to start your notebook, but the result is worth it.

如果您希望您的用户能够重新计算某些部分,您还可以使用MyBinder。启动笔记本需要一些时间,但结果是值得的。

As said by @Mapl, Google can host your notebook with Colab. A nice feature is to compute your cells over a GPU.

正如@Mapl 所说,Google 可以使用Colab托管您的笔记本。一个不错的功能是通过 GPU 计算您的单元。

回答by Denis Rasulev

One more way to achieve this goal would be using JupyterHub.

实现这一目标的一种方法是使用JupyterHub

With JupyterHub you can create a multi-user Hub which spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server. Due to its flexibility and customization options, JupyterHub can be used to serve notebooks to a class of students, a corporate data science group, or a scientific research group.

使用 JupyterHub,您可以创建一个多用户集线器,它可以生成、管理和代理单用户 Jupyter 笔记本服务器的多个实例。由于其灵活性和自定义选项,JupyterHub 可用于为学生班级、企业数据科学小组或科学研究小组提供笔记本。

enter image description here

在此处输入图片说明

回答by Mapl

Google has recently made public its internal Collaboratory project (link here). You can start a notebook in the same way as starting a Google Sheet or Google Doc, and then simply share the notebook or add collaborators..

谷歌最近公开了它的内部协作项目(链接在这里)。您可以像启动 Google Sheet 或 Google Doc 一样启动笔记本,然后只需共享笔记本或添加协作者即可。

For now, this is the easiest way for me.

目前,这对我来说是最简单的方法。