【问题标题】:What happened to the TOC extension for ipython notebook?ipython notebook 的 TOC 扩展发生了什么?
【发布时间】:2014-02-06 22:46:08
【问题描述】:

我正在尝试在新计算机上安装出色的目录扩展。但我再也找不到了。唯一的页面I do find 没有说明如何在 Windows 上安装扩展。

所以.. 我该如何安装它,为什么它不是官方 Ipython 笔记本的一部分?我简直无法理解没有它人们是如何相处的。

【问题讨论】:

  • 很多已经改变 - 见 dreme 的回答!
  • pip3 install --user jupyter_contrib_nbextensions then jupyter contrib nbextension install --user then 激活目录扩展:jupyter nbextension enable toc2/main

标签: jupyter-notebook ipython


【解决方案1】:

我最近使用 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 已添加到 this project 中,它提供了各种 nbextensions 的集合。非常易于安装和管理,值得一试!

【讨论】:

  • 扩展项目运行良好,感谢您的链接。
【解决方案2】:

我不能告诉你具体的 Windows 建议,但认为关键点应该与平台无关:

  1. 创建配置文件(默认配置文件或命名配置文件 - 您可能希望默认启动)。
  2. 找到配置文件所在的位置。
  3. custom.js 文件添加到配置文件中。
  4. 编辑custom.js 文件以指向笔记本扩展代码。

更详细地说,设置配置文件是covered in detail here,但对于默认配置文件,只需转到命令行并输入

ipython profile

接下来,通过在命令行键入

找到您的个人资料的存储位置
ipython locate

打电话给<profile_dir>

其余部分遵循(Windows 等效的!)链接上的说明:<profile_dir> 下方导航到(创建任何尚不存在的目录)

<profile_dir>/static/custom/

并添加custom.js 文件,如图所示。然后编辑第一行,它的"nbextensions/toc" 指向您放置已下载的toc.js 文件的位置。这个位置是相对于&lt;profile_dir&gt;;对我来说我有

<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 版本 - 如果您使用的是早期版本,我强烈建议您在尝试之前升级。

【讨论】:

    【解决方案3】:

    您还可以在以下位置找到官方安装说明:

    https://github.com/minrk/ipython_extensions

    这些说明包括用于从 GitHub 检索 toc.js 和 toc.css 文件的 curl 命令,这对我来说在 linux Mint 上的 bash shell 中运行良好。

    对于 Windows 7,我使用 Git Shell(参见 http://msysgit.github.io/)来执行 curl 命令

    【讨论】:

      【解决方案4】:

      This IPython Notebook 半自动生成 Windows 中 minrk 目录的文件。它不使用“curl”命令或链接,而是将 *.js 和 *.css 文件直接写入您的 IPython Notebook-profile-directory。

      笔记本中有一个名为 '你需要做什么' 的部分 - 遵循它并有一个漂亮的浮动目录:)

      这是一个已经显示的 html 版本: http://htmlpreview.github.io/?https://github.com/ahambi/140824-TOC/blob/master/A%20floating%20table%20of%20contents.htm

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-03-22
        • 1970-01-01
        • 2013-12-10
        • 2022-11-16
        • 1970-01-01
        • 2015-05-19
        • 1970-01-01
        相关资源
        最近更新 更多