IPython Notebook的TOC扩展发生了什么事情?

6
我正在尝试在新电脑上安装一个很棒的目录扩展,但是我找不到它了。唯一能找到的页面这个,没有说明如何在Windows上安装扩展。

那么,我该如何安装它,为什么它不是官方Ipython笔记本的一部分呢?我简直无法理解人们如何在没有它的情况下继续前进。


很多事情已经改变了 - 请看dreme的回答! - dmeu
pip3 install --user jupyter_contrib_nbextensions then jupyter contrib nbextension install --user then Activate the table of content extension: jupyter nbextension enable toc2/main - Paul Rougieux
4个回答

7

我最近成功地在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.jstoc.css 放入 ~/.local/share/jupyter/nbextensions/ 中,则应在此处使用 enable toc编辑 抱歉,我没有注意到原始问题是在 Windows 上。 我不确定对于 Windows Jupyter 是否相同,欢迎任何报告。 更新 现在 toc nbextension 已经添加到 这个项目 中,提供了各种 nbextensions 的集合。它非常容易安装和管理,值得一试!

扩展项目效果很好,感谢提供的链接。 - jgyou

3
我不能为您提供具体的Windows建议,但我认为关键点应该是平台无关的:
  1. 创建一个配置文件(可以是默认配置或命名配置 - 您可能希望从默认配置开始)。
  2. 找到配置文件所在的位置。
  3. custom.js文件添加到配置文件中。
  4. 编辑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的 - 如果您正在使用早期版本,我强烈建议在尝试此操作之前升级。


1

0

这个 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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接