Skip to main content
 首页 » 编程设计

python之是否可以在 nbviewer 中使用 jupyter_contrib_nbextensions

2024年12月31日7exmyth

是否可以使用 jupyter_contrib_nbextensions Collapsible Headings 中的“nbviewer ”扩展名?

我已经通过执行以下步骤在本地使用它:

# Install Jupyterextension package 
pip install jupyter_contrib_nbextensions 
jupyter contrib nbextension install 
 
# Install configurator and enable configurator 
pip install jupyter_nbextensions_configurator 
jupyter nbextensions_configurator enable 

然后我刚刚在 nbextensions 配置器面板中启用了“可折叠标题”。

但是当我将笔记本上传到 GitHub 然后尝试使用 nbviewer 打开它时或 mybinder它启动了笔记本,但没有可折叠标题支持。

我如何“告诉”nbviewer 或 mybinder 我需要它们使用“可折叠标题”扩展?我已经更新了我的 requirements.txt 文件并向其添加了 jupyter_contrib_nbextensions 依赖项,但它看起来像还不够……

请您参考如下方法:

通过关注@AdrienPacifico 和 mybinder documentation我设法得到的建议 jupyter_contrib_nbextensions为两者安装和激活 - 我的本地 Jupyter 服务器和 mybinder服务器只需将所有扩展激活指令放入我存储库根目录中的 postBuild 文件即可。

以下是激活 collapsible_headings 的 requirements.txt 和 postBuild 文件示例扩展名:

requirements.txt

jupyter==1.0.0 
jupyter-contrib-nbextensions==0.5.0 

构建后

jupyter contrib nbextension install --user 
jupyter nbextension enable collapsible_headings/main 

在 mybinder 中启动包含这些文件的存储库后,将为每个用户自动激活 collapsible_headings 扩展。

但我仍然有的唯一问题是我们如何才能为 nbviewer 保留相同的外观和感觉还有……