jupyter全然触ってなかったらjupyter labってのが出ててへーってなったりしてました。
Tabとか押したら補完してくれるんですが、もっとリッチにできないかなーと思ってらLanguageServerのextensionがあったので、今回はそれを試してみました。
動いたレポジトリはここ
GitHub - ara-ta3/jupyterlab-getting-started
$make install install/extension run # pythonのパスがpython3じゃない場合は $make install install/extension run PYTHON=python
で動くはずです
インストール
Installは本家を参考にやりました。
唯一困ったのは、そのままやってもpython用のLanguageServerが起動しなくて jupyter_notebook_config.json
に追加したところでした。
https://github.com/krassowski/jupyterlab-lsp#installation
0. venvの設定とnode.jsの追加
デフォで入ってたpython3とnodebrewで入れたnodeを使いました。
nodeはjupyter-lspで使うらしいです。
$python3 -V Python 3.7.6 $python3 -m venv venv $source venv/bin/activate $node -v v12.15.0
1. pipでjupyterやらlspやらをインストール
$cat requirements.txt jupyterlab jupyter-lsp python-language-server[all] $ pip install -r requirements.txt # ...
2. jupyter extensionをインストール
$jupyter labextension install @krassowski/jupyterlab-lsp # ... # installされたversion $jupyter --version jupyter core : 4.6.3 jupyter-notebook : 6.0.3 qtconsole : not installed ipython : 7.12.0 ipykernel : 5.1.4 jupyter client : 5.3.4 jupyter lab : 1.2.6 nbconvert : 5.6.1 ipywidgets : not installed nbformat : 5.0.4 traitlets : 4.3.3
3. jupyter_notebook_config.jsonに設定追加
{ "LanguageServerManager": { "language_servers": { "python": { "version": 1, "argv": ["python", "-m", "pyls"], "languages": ["python"] } } } }
起動
$jupyter lab # ...
ちゃんと出ました。便利。