jupyter notebook 常用插件安装和踩坑(命令行安装) | 您所在的位置:网站首页 › pr插件安装完后不显示了怎么办 › jupyter notebook 常用插件安装和踩坑(命令行安装) |
手动查看变量类型和代码块执行时间还是有点麻烦,决定装个插件简化下工作 一些快捷键需要在命令模式下使用,使用 esc 或者 Ctrl + m可以进入命令模式。 如果你的插件界面是空白界面,这里会有另类的解决方法。 文章目录 安装pipconda 图形化界面(非必选)pipcondaQ: 图形化插件的界面不显示 启用插件查看当前的插件启用情况Q: 启用插件输错名字后,jupyter nbextension list 显示很乱怎么办? 常用插件介绍Code prettify 代码美化前置安装: yapf Collapsible Headings 按标题折叠Execute time 显示执行时间Hinterland 补全显示Table of Contents (2) 目录生成Q: Navigate 选项显示不全 Toggle all line numbers 显示行号Variable Inspector 变量检查器 小坑Q: Config option template_path not recognized by LenvsHTMLExporter. Did you mean one of: extra_template_paths, template_name, template_paths? 参考链接 安装想要安装插件首先得安装 jupyter_contrib_nbextensions,以下的安装命令直接来自于官方文档。 pip pip install jupyter_contrib_nbextensions jupyter contrib nbextension install --user conda conda install -c conda-forge jupyter_contrib_nbextensions jupyter contrib nbextension install --user 图形化界面(非必选)安装 jupyter_nbextensions_configurator pip pip install jupyter_nbextensions_configurator jupyter nbextensions_configurator enable --user # can be skipped for notebook >=5.3 conda conda install -c conda-forge jupyter_nbextensions_configurator如果你在文件目录界面还是找不到 nbextensions,尝试这个链接:http://localhost:8888/nbextensions,或者进入某个.ipynb文件,点击Edit,最下面有nbextensions config。 ![]() 如果你找到了但打开还是一片空白,那你可能需要降低jupyter的版本重新安装。 如果你不想降版本的话,没有关系,不需要这个界面一样可以安装插件 : )。 (之前因为找不到这个界面,以为装不了插件,不了了之。这次细看命令后,发现 jupyter_nbextensions_configurator 只是 jupyter_nbextensions 的拓展,不是必需品。) 启用插件jupyter_contrib_nbextension 中有很多自带的插件,你可以在仓库中查看相应的文档,也可以在 Unofficial Jupyter Notebook Extensions 查看一些使用上的说明。 下面的GIF图来自于 仓库。 注意,安装新的插件不需要重新运行 jupyter notebook 来加载,刷新网页即可。 查看当前的插件启用情况 jupyter nbextension list切换目录到 config dir 下,编辑 notebook.json 文件,将输错的删去即可。 注意,最后一行不能留,,否则 jupyter nbextension list 会报错。 ![]() 禁用插件:jupyter nbextension disable Code prettify 代码美化Code prettify 插件使用 yapf,可以在 jupyter notebook 中一键美化代码 。 前置安装: yapf在使用Code prettify插件之前,需要先安装yapf,否则会报错:[code_prettify] Error: ModuleNotFoundError No module named ‘yapf’。 pip pip install yapfconda conda install -c conda-forge yapf jupyter nbextension enable code_prettify/code_prettify --user按标题折叠内容(包括标题下的代码块) jupyter nbextension enable collapsible_headings/main --user![]() 会在代码块下方显示执行时间,双击取消显示,Cell -> Execution time 选项卡中还有其他选项。 jupyter nbextension enable execute_time/ExecuteTime --user一直显示补全的内容,等价于按 tab。 jupyter nbextension enable hinterland/hinterland --user Table of Contents (2) 目录生成根据文档中的标题生成目录,可以点击跳转。 注意:如果你的 jupyter 版本过新(打不开图形配置),请不要随意改动侧边栏目录的设置,会有 bug。 jupyter nbextension enable toc2/main --user需要拖动右下角 ![]() 一键显示/隐藏行号,默认快捷键是 L,命令模式下使用。 (快捷键最新版可能有 bug) jupyter nbextension enable toggle_all_line_numbers/main --user![]() ![]() issue #1529 中提到,这个错误是因为 nbconvert >=6.0.0 修改了 template_path 为 template_paths 所导致的,一个解决方法是将 nbconvert 降版本,似乎还有其他的解决方法,我没有细究。 conda install nbconvert=5.6.1 参考链接jupyter_contrib_nbextensions Installing jupyter_contrib_nbextensions Jupyter Notebook Extensions cannot see jupyter nbextension configurator tab |
CopyRight 2018-2019 实验室设备网 版权所有 |