3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

65日目 (解決)Jupyter notebook が Kernel Not Conectedで動かない。

Last updated at Posted at 2019-12-09

#jupyter notebookをインストール

pip install jupyter→さくっと完了、jupyter notebookにてWeb版jupyterが起動、よーしよしと思ったら・・・

##動きが変。
InするのにOutしない。Markdownすら平文のまま。
そのうちkernelがどうこうってエラーがでてNot Conectedとなりました。

スクリーンショット 2019-12-09 13.46.04.png

どういう事なのでしょう。

##ログを見てみる
最初のKernel started:の直後にTraceback (most recent call last):が走ってModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'で終わっています。

[I 13:44:36.598 NotebookApp] Kernel started: 2b1f107e-6695-4f99-bf66-37f048436327
Traceback (most recent call last):
  File "/anaconda3/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/anaconda3/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/anaconda3/lib/python3.6/site-packages/ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "/anaconda3/lib/python3.6/site-packages/ipykernel/__init__.py", line 2, in <module>
    from .connect import *
  File "/anaconda3/lib/python3.6/site-packages/ipykernel/connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir
  File "/anaconda3/lib/python3.6/site-packages/IPython/__init__.py", line 56, in <module>
    from .terminal.embed import embed
  File "/anaconda3/lib/python3.6/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/anaconda3/lib/python3.6/site-packages/IPython/terminal/interactiveshell.py", line 21, in <module>
    from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'
[I 13:44:39.584 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):

その後KernelRestarter: restarting kernel (1/5)で何度か再起動をかけますが、ModuleNotFoundErrorでどれもこれも終了。

#prompt-toolkitってなんだろう?

描画するツールみたいです。
python prompt toolkitの紹介と動作を理解するメモ
https://vaaaaaanquish.hatenablog.com/entry/2019/07/06/213909

##インストールされている?

$ pip list | grep prompt-toolkit
  prompt-toolkit                     1.0.18

ある。

##最新版は?
prompt-toolkit 3.0.2
https://pypi.org/project/prompt-toolkit/

1.0と3.0じゃあだいぶ違うだろうなあ。

#prompt_toolkit.formatted_textはある?

##1.0にはなさそう。
https://python-prompt-toolkit.readthedocs.io/en/1.0.15/search.html?q=formatted_text&check_keywords=yes&area=default

##2.0にはある。
https://python-prompt-toolkit.readthedocs.io/en/latest/index.html

##3.0でふえている。
https://python-prompt-toolkit.readthedocs.io/en/master/index.html

###ということは、2.0にアップしたらよさそうです!
さっそく。

$ pip install --upgrade prompt-toolkit==2
ERROR: Could not find a version that satisfies the requirement prompt-toolkit==2 (from versions: 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 0.9, 0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 0.23, 0.25, 0.26, 0.28, 0.30, 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.40, 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.50, 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.60, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.0.7, 1.0.8, 1.0.9, 1.0.10, 1.0.13, 1.0.14, 1.0.15, 1.0.16, 1.0.17, 1.0.18, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9, 2.0.10, 3.0.0, 3.0.1, 3.0.2)
ERROR: No matching distribution found for prompt-toolkit==2

小数点までしっかり指定しなきゃらしい。2系の最終盤でいいかな。

$ pip install --upgrade prompt-toolkit==2.0.10
Collecting prompt-toolkit==2.0.10
  Downloading https://files.pythonhosted.org/packages/87/61/2dfea88583d5454e3a64f9308a686071d58d59a55db638268a6413e1eb6d/prompt_toolkit-2.0.10-py3-none-any.whl (340kB)
     |████████████████████████████████| 348kB 1.4MB/s 
Requirement already satisfied, skipping upgrade: six>=1.9.0 in /anaconda3/lib/python3.6/site-packages (from prompt-toolkit==2.0.10) (1.13.0)
Requirement already satisfied, skipping upgrade: wcwidth in /anaconda3/lib/python3.6/site-packages (from prompt-toolkit==2.0.10) (0.1.7)
ERROR: jupyter-console 5.2.0 has requirement prompt-toolkit<2.0.0,>=1.0.0, but you'll have prompt-toolkit 2.0.10 which is incompatible.
Installing collected packages: prompt-toolkit
  Found existing installation: prompt-toolkit 1.0.18
    Uninstalling prompt-toolkit-1.0.18:
      Successfully uninstalled prompt-toolkit-1.0.18
Successfully installed prompt-toolkit-2.0.10

いい感じです。
jupyter notebookを起動してみます。

$ jupyter notebook
/anaconda3/lib/python3.6/site-packages/notebook/services/kernels/kernelmanager.py:19: VisibleDeprecationWarning: zmq.eventloop.minitornado is deprecated in pyzmq 14.0 and will be removed.

Web版でテスト。
スクリーンショット 2019-12-09 14.45.25.png

#OK!
できました!

(1時間)

3
4
2

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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?