在只读视图(如 HTML 文件)中打开 IPython 笔记本 (*.ipynb)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37145454/
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
Open IPython notebooks (*.ipynb) in read-only view (like a HTML file)
提问by chentingpc
Nowadays with more and more IPython notebook files (*.ipynb) around, it is very disturbing every time when I want to peek at some notebook I have to open a server for it, and cannot do it in read-only mode. Due to auto-save I can accidentally change the file when reading it if not in read-only mode.
现在有越来越多的IPython notebook文件(*.ipynb),每次我想偷看某个notebook时都非常烦人,我必须为它打开一个服务器,而且不能在只读模式下进行。由于自动保存,如果不是只读模式,我可能会在读取文件时意外更改文件。
I hope something like this: ipython notebook mynb.ipynb --read-only
would work, but sadly it doesn't (although still it creates a server which I don't really want in read-only view). What I really want is to open an ipynb file like a HTML file for reading; currently it seems a missing view of ipynb file, and now the notebook is more like a black-box or near-binary file alone.
我希望这样的事情:ipython notebook mynb.ipynb --read-only
会工作,但遗憾的是它没有(尽管它仍然创建了一个我在只读视图中并不真正想要的服务器)。我真正想要的是像HTML文件一样打开一个ipynb文件进行阅读;目前似乎缺少 ipynb 文件的视图,现在笔记本更像是一个黑匣子或接近二进制文件。
(P.S. I am using Linux/Ubuntu.)
(PS 我使用的是 Linux/Ubuntu。)
回答by Tanu
Try this ipynb Viewer. This renders ipython notebook as a static web-page. Also ypu can convert ipyhton notebook to other formats using
试试这个ipynb 查看器。这将 ipython notebook 呈现为静态网页。ypu 还可以使用以下方法将 ipyhton notebook 转换为其他格式
ipython nbconvert --to FORMAT notebook.ipynb.
Refer Convert Ipython notebook to other formats. Using this you can convert ipython notebook to HTML.
请参阅将 Ipython 笔记本转换为其他格式。使用它,您可以将 ipython notebook 转换为 HTML。
回答by blahblahetcetc
回答by Denis Rasulev
You may also want to try nteractapp (https://nteract.io)
您可能还想尝试使用nteract应用程序 ( https://nteract.io)
nteractis a desktop application that allows you to develop rich documents that contain prose, executable code (in almost any language!), and images.
interact是一个桌面应用程序,它允许您开发包含散文、可执行代码(几乎任何语言!)和图像的丰富文档。
Hereyou can find more detailed review of the app.
在这里您可以找到对该应用程序的更详细评论。
It is completely free and very convenient tool by itself and I use it quite often to see other ipynb files if needed and for quick development.
它本身是完全免费且非常方便的工具,如果需要和快速开发,我经常使用它来查看其他 ipynb 文件。
回答by Mark Amery
The best I can suggest - unfortunately still a bit verbose - is using nbconvert
to create a HTML version of the file, then opening it with your browser. Below are commands to do this (assuming that your browser is set up as the default program to handle .html files). Just replace yournotebook.ipynb
with your real Notebook name.
我能建议的最好的 - 不幸的是仍然有点冗长 - 是nbconvert
用来创建文件的 HTML 版本,然后用浏览器打开它。下面是执行此操作的命令(假设您的浏览器设置为处理 .html 文件的默认程序)。只需替换yournotebook.ipynb
为您的真实笔记本名称即可。
jupyter nbconvert --to html yournotebook.ipynb --output /tmp/notebook.html &&
xdg-open /tmp/notebook.html
苹果系统
jupyter nbconvert --to html yournotebook.ipynb --output /tmp/notebook.html &&
open /tmp/notebook.html
视窗
jupyter nbconvert --to html yournotebook.ipynb --output "%TEMP%\notebook.html" && start "" "%TEMP%\notebook.html"
(Note that if you want to do this in bulk, perhaps in a loop in a script, you'll probably want to modify the commands above to not always use the same filename for the HTML file, to avoid the race condition where the HTML file has been overwritten by the time the browser actually gets round to starting to read it.)
(请注意,如果您想批量执行此操作,也许在脚本中的循环中执行此操作,您可能需要修改上面的命令,以便不总是对 HTML 文件使用相同的文件名,以避免出现 HTML当浏览器真正开始阅读它时,文件已被覆盖。)
回答by Sabarish
I was able to read .ipynb files as html in visual code. You would need a python plugin for it which visual code auto detects. Fairly straight forward after that.
我能够在可视代码中将 .ipynb 文件读取为 html。你需要一个 python 插件,它可以自动检测可视化代码。在那之后相当直接。
回答by Holger Brandl
Intellij IDEA (which is also available as free open-source community edition) can render ipynb
files as well. In fact it also allows to author notebooks, so it's not just a viewer.
Intellij IDEA(也可作为免费的开源社区版提供)也可以渲染ipynb
文件。事实上,它还允许创作笔记本,所以它不仅仅是一个查看器。
It can be used via file type associations or via the command line launcher (e.g. idea foo.pynb
).
它可以通过文件类型关联或通过命令行启动器(例如idea foo.pynb
)使用。
回答by clockware
I use Github Gist for that. You'll need a Github account.
为此,我使用 Github Gist。您需要一个 Github 帐户。
If you specify *.ipynb file extension there for your content copy/paste, it'll detect it and format as html view. You'll be able even sharing it with someone using link if that's interesting. No tools required other than having a browser.
如果你在那里为你的内容复制/粘贴指定 *.ipynb 文件扩展名,它会检测它并格式化为 html 视图。如果这很有趣,您甚至可以使用链接与某人共享它。除了有浏览器,不需要任何工具。
I've found some glitches in formatting though, mostly with output plots, but it's reasonably rare.
不过,我在格式设置方面发现了一些小故障,主要是输出图,但这种情况相当罕见。
Random example here: https://gist.github.com/Clockware/aa7e01722579841d5888ca83385a5f1d
随机示例:https: //gist.github.com/Clockware/aa7e01722579841d5888ca83385a5f1d