【目的】jupyter notebookにおいて、Jupyter isortを使用したい
【経緯】
import文の並び順のフォーマットをjupyter notebookで行いたいと思い、調べたら下記URLにたどり着きました。
https://github.com/benabel/jupyter-isort
に従って、
1:pip install isort
2:jupyter nbextension install https://github.com/benjaminabel/jupyter-isort/archive/master.zip --user
3:jupyter nbextension enable jupyter-isort-master/jupyter-isort
を実行したところ、下記画像の青枠ように機能を追加することができました。
しかし、機能は実行できず、赤枠のようにエラーが出てしまいます。
【エラー】
isort extension
Error : AttributeError
module 'isort' has no attribute 'SortImports'
【調査・試したこと】
① isortとpythonの互換性に不一致は見られなかった
②「module 'isort' has no attribute 'SortImports'」の原因をChatGPTに質問したところ、pip install --upgrade isortを進められたが試しても改善が見られない
③ 画像のセル内のコードをUni.pyにして、ターミナル上でisort Uni.pyを実行したところ問題なく処理はできた(しかし、やりたいのは画像内青枠のボタンを使用した選択セルに対してのisort処理)
④ https://github.com/benabel/jupyter-isortのjupyter-isort.js「function code_exec_callback(msg)」を見ても、isortライブラリの問題(つまり、module 'isort' has no attribute 'SortImports')にしかないと考えてしまう。しかし、そうなると④の問題に戻る
<<< 質問 >>>
・エラーを改善し、この機能が使える方法を教えてください
よろしくお願いいたします。
(追記)nbextensionsのisort formatterは実行しても何も起きなかったです
*【環境】
Anaconda3, Windows11, python, jupyter notebook6.5.4、Anaconda Navigator2.4.1
*【nbextensionsの環境設定】
下記URLに従ってインストール
https://smile-jsp.hateblo.jp/entry/2020/10/04/200458

回答1件
あなたの回答
tips
プレビュー