LoginSignup
8
4

More than 1 year has passed since last update.

[2023年2月更新] jupyterlab に jupyterlab-vim をインストールしたときのメモ

Last updated at Posted at 2021-05-01

概要

新しいサーバの jupyterlab に jupyterlab-vim をインストールしたときのメモ。

jupyterlab が新しくなっていて、以前使えたパッケージが動かなかったり、WebUI から third-party extension をインストールできるようになっていた。

やったことを簡潔に書くと、1)conda でインストールしたパッケージが動かなくて、2)jupyterlab の WebUI からインストールしたら動いた、というだけなのですが、せっかくなので他のパッケージや別の方法も試して結果をまとめてみました。

環境

初回投稿時

  • Python 3.8.8
  • jupyterlab 3.0.14
  • conda 4.10.1 ← 古すぎ?間違えたかも

2023年2月更新時

  • Python 3.9.16
  • jupyterlab 3.6.1
  • conda 22.9.0

色々なインストール方法とその結果

[OK] conda install -q -y -c conda-forge jupyterlab_vim (2023年2月8日追記)

anaconda にちゃんと動くパッケージがありました(初回投稿時は見つけれられなかった or まだ無かった?)。

$ conda install -q -y -c conda-forge jupyterlab_vim

[NG] conda install -q -y -c krinsman jupyterlab-vim

これは古くて動かなかった。

$ conda install -q -y -c krinsman jupyterlab-vim

outdated らしい

$ jupyter-labextension list                                                            [2/1841]
JupyterLab v3.0.14
/opt/anaconda3/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /opt/anaconda3/share/jupyter/lab
        jupyterlab_vim v0.8.0 enabled  X

   The following extension are outdated:
        jupyterlab_vim

   Consider running "jupyter labextension update --all" to check for updates.

言われるとおりに update

$ jupyter labextension update --all
An error occured.
ValueError: Please install nodejs >=12.0.0 before continuing. nodejs may be installed using conda or directly from the nodejs website.
See the log file for details:  /tmp/jupyterlab-debug-cra9k25q.log

nodejs 必要

$ conda install -y -c conda-forge nodeenv
$ mkdir .nodeenv
$ cd .nodeenv
$ nodeenv --node 15.14.0 node15
 * Install prebuilt node (15.14.0) ..... done.
$ cd

activate

$ source ~/.nodeenv/node15/bin/activate

retry update

$ jupyter labextension update --all
No compatible version found for jupyterlab_vim!

: (

[OK] jupyterlab の WebUI からインストール

これで正常に動きました。third-party extension を WebUI からインストールできるようになっていたんですね。

  1. 画面左端のパズルみたいなアイコンをクリック
  2. 検索窓から "vim" などで検索
  3. @axlair/jupyterlab_vim が出てくるのでインストール

jupyterlab_vim.png

[OK] jupyter labextension install @axlair/jupyterlab_vim


2023年2月8日追記:

jupyter labextension install command は非推奨になったようです。

コマンドを実行すると以下のメッセージが出ます。

(Deprecated) Installing extensions with the jupyter labextension install command is now deprecated and will be removed in a future major version of JupyterLab.

Users should manage prebuilt extensions with package managers like pip and conda, and extension authors are encouraged to distribute their extensions as prebuilt packages 

2023年2月8日現在、まだ使えますが、近いうちに削除されると思われるので、WebUI / conda / pip を使いましょう。


jupyter labextension でもインストールできます。パッケージ名を "jupyterlab_vim" にすると違う結果になるので注意(後述)。

$ jupyter labextension install @axlair/jupyterlab_vim
Building jupyterlab assets (production, minimized)

$ jupyter labextension list
JupyterLab v3.0.14
/opt/anaconda3/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)

Other labextensions (built into JupyterLab)
   app dir: /opt/anaconda3/share/jupyter/lab
        @axlair/jupyterlab_vim v0.13.4 enabled OK

ちなみにこの方法だと pip 管理にはならないっぽい。conda install 派の人(私とか)は pip install よりこの方がスッキリするかもしれませんね。

$ pip list | grep vim
$

[OK] pip install jupyterlab_vim

おそらく最も多くの人が使っている方法。ちゃんと動く。

$ pip install jupyterlab_vim

$ jupyter-labextension list
JupyterLab v3.0.14
/opt/anaconda3/share/jupyter/labextensions
        @jupyter-widgets/jupyterlab-manager v3.0.0 enabled OK (python, jupyterlab_widgets)
        @axlair/jupyterlab_vim v0.13.4 enabled OK (python, jupyterlab_vim)

こちらはもちろん pip で管理されます。

$ pip list | grep vim
jupyterlab-vim                     0.13.4

[NG] jupyter-labextension install jupyterlab_vim

前はこのパッケージ使っていた気がするけど、今は not supported。@axlair/jupyterlab_vim を使いましょう。

$ jupyter-labextension install jupyterlab_vim
An error occured.
ValueError: The extension "jupyterlab_vim" does not yet support the current version of JupyterLab.


Conflicting Dependencies:
JupyterLab              Extension      Package
>=3.0.9 <3.1.0          >=1.0.1 <2.0.0 @jupyterlab/application
>=3.0.7 <3.1.0          >=1.0.1 <2.0.0 @jupyterlab/codemirror
>=3.0.9 <3.1.0          >=1.0.1 <2.0.0 @jupyterlab/notebook
See the log file for details:  /tmp/jupyterlab-debug-8xiie8o3.log

以上です。

8
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
4