必须安装jupyter_contrib_nbextensions和jupyter_nbextensions_configurator两个包,并执行install与enable命令,否则nbextensions选项卡不可见;启用后需关闭兼容性限制才能使用目录导航、代码折叠等功能。

要在Jupyter Notebook中启用代码折叠、目录导航、变量查看等实用功能,必须正确安装并激活插件扩展,否则即使装了包也看不到Nbextensions选项卡。
装对两个核心包:仓库+菜单缺一不可
第一步:安装插件仓库 jupyter_contrib_nbextensions,它提供50+个真实可用的扩展(如Codefolding、Table of Contents),没有它,后续所有操作都无效。
第二步:安装配置菜单 jupyter_nbextensions_configurator,它在Jupyter顶部生成“Nbextensions”标签页,让你用勾选方式开关插件。
第三步:执行 jupyter contrib nbextension install --user ——这一步把插件的前端文件(JS/CSS)复制到Jupyter可识别路径,【跳过此步,插件图标不会出现在界面】。
第四步:启用配置器 jupyter nbextension enable --py jupyter_nbextensions_configurator --user ——让“Nbextensions”菜单真正加载出来,不是仅装包就完事。
conda和pip双路径安装法
方法一(conda用户首选):
conda install -c conda-forge jupyter_contrib_nbextensions → conda install -c conda-forge jupyter_nbextensions_configurator → jupyter contrib nbextension install --user → jupyter nbextension enable --py jupyter_nbextensions_configurator --sys-prefix
方法二(pip用户注意权限):
pip install jupyter_contrib_nbextensions jupyter_nbextensions_configurator → jupyter contrib nbextension install --user → jupyter nbextension enable --py jupyter_nbextensions_configurator --user
提示:Windows用户若用Anaconda Prompt,务必以管理员身份运行,否则--user可能因权限不足写入失败。
启动后必做的界面配置
打开Jupyter Notebook,点击顶部出现的“Nbextensions”选项卡。
取消勾选 “Disable configuration for nbextensions without explicit compatibility” ——这个选项默认开启会屏蔽所有未声明兼容性的插件,【不关掉它,Table of Contents、Variable Inspector等主流插件全灰显】。
勾选你想要的功能,比如“Table of Contents (2)”、“Code folding”、“Variable Inspector”,立刻生效,无需重启。











