【Python】PyCharmからJupyterNotebookをでもエラーが出る場合の対処

【Python】PyCharmからJupyterNotebookをでもエラーが出る場合の対処


# pycharm # python

環境

JetBrains PyCharm Professional Edition with Anaconda plugin 2019.2.3 x64 conda==4.5.11 notebook==4.30

 

状態・エラー内容

どうやらデータの形式が何かおかしい模様。

[I 11:43:35.951 NotebookApp] [nb_conda_kernels] enabled, 5 kernels found
[I 11:43:37.628 NotebookApp] [nb_anacondacloud] enabled
[I 11:43:37.632 NotebookApp] [nb_conda] enabled
[I 11:43:37.675 NotebookApp] \u2713 nbpresent HTML export ENABLED
[W 11:43:37.675 NotebookApp] \u2717 nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 11:43:37.794 NotebookApp] Serving notebooks from local directory: \work\mi_pj\analyze
[I 11:43:37.794 NotebookApp] 0 active kernels 
[I 11:43:37.794 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 11:43:37.794 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 11:44:36.617 NotebookApp] 302 GET /?token=null (::1) 1.00ms
[I 11:44:45.055 NotebookApp] Kernel started: df624e6d-af93-4ddc-a876-d0debd33f2d0
[I 11:45:14.746 NotebookApp] 302 GET /api/kernelspecs/ (127.0.0.1) 0.00ms
[W 11:45:14.759 NotebookApp] Missing field in JSON data: notebook.path
[W 11:45:14.759 NotebookApp] 400 POST /api/sessions (127.0.0.1) 1.00ms referer=None
[I 11:45:18.397 NotebookApp] 302 GET /api/kernelspecs/ (127.0.0.1) 0.97ms
[W 11:45:18.405 NotebookApp] Missing field in JSON data: notebook.path
[W 11:45:18.405 NotebookApp] 400 POST /api/sessions (127.0.0.1) 1.00ms referer=None
[I 11:45:47.680 NotebookApp] Kernel shutdown: df624e6d-af93-4ddc-a876-d0debd33f2d0

ブラウザから http://localhost:8888/ にアクセスをすると普通にセルの実行は可能

 

原因

以下にある通り、notebookのバージョンが古いためでした。 (先人に環境を合わせようと無理したのがいけなかった…)

https://github.com/jupyter/jupyter/issues/301

対処

conda update notebook もしくは pycharmの画面からnotebookをアップデートすればOKです。

現状私の環境ではnotebook==5.7.0で問題なく動作しています。

[I 12:07:08.653 NotebookApp] [nb_conda_kernels] enabled, 5 kernels found
[I 12:07:10.375 NotebookApp] [nb_anacondacloud] enabled
[I 12:07:10.379 NotebookApp] [nb_conda] enabled
[I 12:07:10.428 NotebookApp] \u2713 nbpresent HTML export ENABLED
[W 12:07:10.428 NotebookApp] \u2717 nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 12:07:10.428 NotebookApp] Serving notebooks from local directory: \work\mi_pj\analyze
[I 12:07:10.428 NotebookApp] The Jupyter Notebook is running at:
[I 12:07:10.428 NotebookApp] http://localhost:8888/?token=cfde46520ez43b7a799ad7343548ec83886adc1f82f0ea96
[I 12:07:10.428 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 12:07:10.429 NotebookApp] 

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=cfde46530ea47b7a099ac7367548ec83886adc1f82f0ea96

いきなりこういうの出ると焦りますねー。