[PYTHON] Day 65 (Solution) Jupyter notebook does not work with Kernel Not Conected.

Install jupyter notebook

pip install jupyter → Completed quickly, the web version of jupyter started with jupyter notebook, if you think it's okay ...

The movement is strange.

In but not out. Even Markdown remains in plain text. Eventually, the kernel got an error and became Not Conected.

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

What does that mean?

Take a look at the log

Immediately after the first Kernel started:, Traceback (most recent call last): runs and ends with 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):

After that, I restarted several times with Kernel Restarter: restarting kernel (1/5), but all of them ended with ModuleNotFoundError.

What is prompt-toolkit?

It looks like a drawing tool. A note about the introduction and operation of the python prompt toolkit https://vaaaaaanquish.hatenablog.com/entry/2019/07/06/213909

Is it installed?

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

is there.

What is the latest version?

prompt-toolkit 3.0.2 https://pypi.org/project/prompt-toolkit/

1.0 and 3.0 would be quite different.

Is there prompt_toolkit.formatted_text?

It doesn't seem to be 1.0.

https://python-prompt-toolkit.readthedocs.io/en/1.0.15/search.html?q=formatted_text&check_keywords=yes&area=default

It's in 2.0.

https://python-prompt-toolkit.readthedocs.io/en/latest/index.html

It has increased in 3.0.

https://python-prompt-toolkit.readthedocs.io/en/master/index.html

That means it would be nice to upgrade to 2.0!

Immediately.

$ 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

It seems that you have to specify the decimal point firmly. Is it okay with the final version of the 2nd series?

$ 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

feel well. Try starting 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.

Tested on the web version. スクリーンショット 2019-12-09 14.45.25.png

OK! It's done!

(1 hour)

Recommended Posts

Day 65 (Solution) Jupyter notebook does not work with Kernel Not Conected.
Jupyter Notebook does not show matplotlib graphs
gqlgen command does not work with go gqlgen
When wildcard specification does not work with pylint
jupyter notebook does not start on mac fish
Right click event acquisition does not work with opencv-python
Sparse modeling: Chapter 5 From exact solution to approximate solution
Kernel Method with Python
Day 65 (Solution) Jupyter notebook does not work with Kernel Not Conected.
PRML Chapter 7 Related Vector Machine Python Implementation for Regression Problems
Using Graphviz with Jupyter Notebook
Use pip with Jupyter Notebook
Use Cython with Jupyter Notebook
Play with Jupyter Notebook (IPython Notebook)
Browser does not open automatically when jupyter notebook is started
The usual way to add a Kernel with Jupyter Notebook
Connect the Jupyter Notebook kernel to Spyder with Jupytext enabled
Solution when background-cover of Linux version VS Code does not work
Allow external connections with jupyter notebook
Formatting with autopep8 on Jupyter notebook
Visualize decision trees with jupyter notebook
Make a sound with Jupyter notebook
LocateCenterOnScreen does not work on PyAutoGui
Use markdown with jupyter notebook (with shortcut)
Add more kernels with Jupyter Notebook
Convenient analysis with Pandas + Jupyter notebook
Jupyter does not show matplotlib graph
How to fix a bug that jupyter notebook does not start automatically
(Under investigation) USB camera that does not work with WebRTC on RPi4
Use nb extensions with Anaconda's Jupyter notebook
Use apache Spark with jupyter notebook (IPython notebook)
I want to blog with Jupyter Notebook
Use Jupyter Lab and Jupyter Notebook with EC2
Try SVM with scikit-learn on Jupyter Notebook
[VScode] autopep8 format does not work [Python]
How to use jupyter notebook with ABCI
Linking python and JavaScript with jupyter notebook
Using Java's Jupyter Kernel with Google Colaboratory
[Jupyter Notebook memo] Display kanji with matplotlib
Rich cell output with Jupyter Notebook (IPython)
What to do when the graph does not appear in jupyter (ipython) notebook