jupyterlab 插件推荐
本文最后更新于 1021 天前,其中的信息可能已经有所发展或是发生改变。

目前自己使用的几个插件,后续再更新。
jupyter 插件话题 topics:jupyterlab-extension

插件相关常用命令:

  • 查看已安装插件:
    jupyter labextension list
    
  • 查看 serverextension:
    jupyter serverextension list
    
  • 更新已安装插件:
    jupyter labextension update --all
    

注意:下面插件的安装方式和快捷键等配置会随版本变动,建议去官方 repo 中查看最新文档。

1. 插件前置环境 – node/npm

插件需要前置安装 nodejs 与 npm,推荐安装较新的版本,有的插件会要求新版本

此处采用解压官方编译的二进制包的方式安装。

  1. 官方下载地址 nodejs download,此处下载 Linux Binaries (x64)

  2. 解压:

    xz -d node-v12.19.0-linux-x64.tar.xz
    tar --strip-components 1 -xvf node-v12.19.0-linux-x64.tar.xz -C /usr/local
    

    解压之后即可使用,但部分插件会需要使用 yarn,下面安装一下。

  3. 安装 yarn:

    npm install -g yarn
    
  4. 不推荐更改 npm 镜像源,目前测试淘宝源发现部分插件的部分版本会找不到,建议保留官方默认镜像。

2. 插件推荐

2.1 jupyterlab-toc: 生成目录

此插件的功能将集成到 jupyterlab 3.0,即 3.0 以后不要在安装此插件。

jupyterlab/jupyterlab-toc:检索标题,生成目录树(注意: 每个标题都要在 cell 的首行)。

安装:

jupyter labextension install @jupyterlab/toc

效果图:

image-20201214184210417

figure 1

2.2 jupyterlab_code_formatter

ryantam626/jupyterlab_code_formatter:代码格式化

安装:

  1. 安装 frontend:
    jupyter labextension install @ryantam626/jupyterlab_code_formatter
    

    查看插件版本:

    jupyter labextension list | grep jupyterlab_code_formatter
    
  2. 安装格式化规范:
    pip install isort black autopep8
    
  3. 安装 backend:
    pip install jupyterlab_code_formatter==填写上面看到的版本
    

    如果版本不一致,会导致插件无法使用!

  4. 启用:

    jupyter serverextension enable --py jupyterlab_code_formatter
    
  5. 配置默认规范:

    以 autopep8 为例。在 Settings -> Advanced Setting Editor -> Jupyterlab Code Formatter,下面内容放到 User Overrides 里

    {
       "preferences": {
           "default_formatter": {
               "python": "autopep8"
           }
       }
    }
    
  6. 配置快捷键:

    以 autopep8 为例。在 Settings -> Advanced Setting Editor -> Keyboard Shortcuts,下面内容放到 User Overrides 里:

    {
       "shortcuts": [
           {
               "command": "jupyterlab_code_formatter:autopep8",
               "keys": [
                   "Alt C"
               ],
               "selector": ".jp-Notebook.jp-mod-editMode"
           }
       ]
    }
    

2.3 plotly

plotly.py: 使 jupyterlab 内嵌 plotly 的图形,这样可以非常方便地图形交互。

安装:

pip install plotly  # plotly 库

pip install ipywidgets  # 插件依赖

jupyter labextension install jupyterlab-plotly  # 插件

效果图:

image-20201214183912267

这样可以使用右上角的工具操作绘制的图形。

2.4 jupyterlab-variableInspector

lckr/jupyterlab-variableInspector:在变量工作区就可以看到当前 notebook 中的变量、变量类型、变量大小等信息。

安装:

jupyter labextension install @lckr/jupyterlab_variableinspector

如果需要在 Inspector 里使用可交互的部件,那需要安装其他扩展,这里不再粘贴,见作者 repo 吧。

效果图:

1541765039961

评论

  1. blood
    3年前
    2020-10-31 21:17:42

    ⚡ myenv ~❯ jupyter labextension install @jupyterlab/toc
    An error occured.
    ValueError: “@jupyterlab/toc” is not a valid npm package
    See the log file for details: C:\Users\HZH\AppData\Local\Temp\jupyterlab-debug-sm9pcp63.log

    报了这个错,因为有什么解决办法吗?

    • root 博主
      3年前
      2020-11-03 14:31:41

      尝试以下步骤定位下问题:

      jupyter labextension install @jupyterlab/toc  --no-build  # 仅下载包,不build
      jupyter lab build --debug  # build 时显示信息
      

      看看 build 的错误信息。
      另外,可以用 npm install 看下 npm 包能否安装:

      npm i @jupyterlab/toc

  2. JohnFelix
    3年前
    2020-7-02 18:16:32

    插件我都是用labextension安装的,然后重启还是出现了插件功能不生效的问题;还有就是我安装了kite,代码补全插件,然后在lab界面中Uninstall之后再重新安装,再执行jupyter labextension list,一直有一个Uninstalled core extensions: @kiteco/jupyterlab-kite,然后这个插件用不了了

  3. JohnFelix
    3年前
    2020-7-02 16:18:07

    jupyter-lab安装插件并且enable,但是在notebook中没有生效可能是什么问题,或者怎么让插件设置变动立即生效,再或者怎么让jupyter-lab快速reload,多谢解答

    • root 博主
      3年前
      2020-7-02 17:04:14

      如果 lab 的插件正确安装且版本匹配的话,需要重启 lab 才能加载。(这里 lab 指的是 jupyterlab,其插件和 jupyternotebook 目前还是不通用的)
      有时由于版本原因,jupyter labextension list 看到 enable 的插件也不能加载,这个问题在插件 jupyterlab_code_formatter 中出现过,相关其 issue: format cammand not shown in jupyterlab
      不知道你是插件版本问题呢?还是没有重启 lab。

  4. root 博主
    4年前
    2020-1-13 11:49:33

    通过已安装的插件列表确认下是否成功安装:

    jupyter labextension list
    

    如果有 类似:@jupyterlab/toc v1.0.1 enabled ok 这样的说明已经成功安装并启动了,那重启 jupyterlab 试试。
    如果这个插件状态是 disabled,那输入这个来启用插件:

    jupyter labextension enable @jupyterlab/toc
    
  5. 4年前
    2019-12-02 12:30:45

    输入上面的安装指令后,cmd.exe会显示以下错误:

    An error occured.
    ValueError: “@jupyterlab/toc” is not a valid npm package

    这个是怎么回事?我是用的是淘宝的 cnpm 包管理器。

    • blood
      3年前
      2020-10-31 21:19:05

      请问这个问题解决了吗?我遇到了同样的问题

  6. root 博主
    4年前
    2019-5-06 21:59:41

    目前还没有这样的插件,不过应该过一两个月就会出吧。github 有人提交过这个想法。repo: jupyterlab, issue:Is any way to highlight the selected word

    • guaidou
      4年前
      2019-5-06 22:01:48

      嗯嗯,好滴,多谢啦~

      • root 博主
        4年前
        2019-5-06 22:09:44

        客气。现在使用时没有这个功能,我是这么做的,在 cell 里 ctrl+f 搜索(figure 1),然后也会有高亮(figure 2),哈哈哈。
        imgNotFound, imgNotFound

  7. root 博主
    4年前
    2019-5-06 21:46:20

    好吧,这样的插件我不知道 lab 有没有。

  8. root 博主
    4年前
    2019-4-28 19:18:46

    抱歉,现在才看到。你指的是 jupyterlab 建立notebook cell内代码的颜色高亮吗?

    • guaidou
      4年前
      2019-5-05 13:21:37

      对的呢。就是选中变量,这个变量就会高亮。highlight selected word

      • root 博主
        4年前
        2019-5-05 15:52:58

        你指的是这个效果?imgNotFound

  9. root 博主
    5年前
    2019-3-06 21:14:24

    哈哈哈,都是从网上大佬那里搜集来的特效。

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇