那么,我该如何安装它,为什么它不是官方Ipython笔记本的一部分呢?我简直无法理解人们如何在没有它的情况下继续前进。
那么,我该如何安装它,为什么它不是官方Ipython笔记本的一部分呢?我简直无法理解人们如何在没有它的情况下继续前进。
我最近成功地在Jupyter 4(即ipython notebook 4)上安装了toc nbextension扩展。实际上,现在安装扩展比以前更容易了 :)
我在这里发布我的解决方案,希望能对您有所帮助。
## download
mkdir toc
cd toc
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.js
wget https://raw.githubusercontent.com/minrk/ipython_extensions/master/nbextensions/toc.css
## install and enable
cd ..
jupyter-nbextension install --user toc
jupyter-nbextension enable toc/toc
install
将把 toc
复制到 ~/.local/share/jupyter/nbextensions/
enable
将修改 ~/.jupyter/nbconfig/notebook.json
您可以查看这两个地方以了解发生了什么。enable toc/toc
是因为 toc.js
在 ~/.local/share/jupyter/nbextensions/toc/
中。
如果您直接将 toc.js
和 toc.css
放入 ~/.local/share/jupyter/nbextensions/
中,则应在此处使用 enable toc
。
编辑
抱歉,我没有注意到原始问题是在 Windows 上。 我不确定对于 Windows Jupyter 是否相同,欢迎任何报告。
更新
现在 toc nbextension 已经添加到 这个项目 中,提供了各种 nbextensions 的集合。它非常容易安装和管理,值得一试!custom.js
文件添加到配置文件中。custom.js
文件以指向笔记本扩展代码。ipython profile
ipython locate
拨打那个<profile_dir>
。
其余部分按照您所拥有的链接中的(Windows等效的)说明进行操作:在<profile_dir>
下方导航(创建任何尚不存在的目录)。
<profile_dir>/static/custom/
您需要按照以下步骤将custom.js
文件添加到项目中并进行编辑。首先,找到第一行代码,将其中的"nbextensions/toc"
指向您下载的toc.js
文件放置的位置。该位置相对于<profile_dir>
来说,对于我而言是
<profile_dir>/static/custom/custom.js
<profile_dir>/static/custom/nbextensions/toc.js
<profile_dir>/static/custom/nbextensions/toc.css
自定义脚本 custom.js 的第一行内容为:
require(["/static/custom/nbextensions/toc.js"], function (toc) {
最后,请注意这是基于笔记本版本1.1.0的 - 如果您正在使用早期版本,我强烈建议在尝试此操作之前升级。
你也可以在以下链接中找到官方的安装指南:
https://github.com/minrk/ipython_extensions
这些说明包括使用curl命令从GitHub检索toc.js和toc.css文件,对于我在Linux Mint的bash shell中运行良好。这个 IPython Notebook 可以在 Windows 中半自动地为 minrk 的目录生成表格文件。 它不使用 'curl' 命令或链接,而是直接将 *.js 和 *.css 文件写入你的 IPython Notebook 配置文件夹。
笔记本中有一个名为“你需要做什么”的部分 - 按照它并拥有一个漂亮的浮动目录:)
这里有一个 HTML 版本,它已经显示出来了: http://htmlpreview.github.io/?https://github.com/ahambi/140824-TOC/blob/master/A%20floating%20table%20of%20contents.htm
pip3 install --user jupyter_contrib_nbextensions
thenjupyter contrib nbextension install --user
then Activate the table of content extension:jupyter nbextension enable toc2/main
- Paul Rougieux