notebook: Kernel crashes with ModuleNotFoundError on 'prompt_toolkit.formatted_text'
With a fresh install of Jupyter in a clean pipenv or virtualenv, a new notebook crashes immediately upon launch with the following in terminal:
[I 13:39:55.748 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/IPython/__init__.py", line 55, in <module>
from .terminal.embed import embed
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/IPython/terminal/embed.py", line 16, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/Users/kat/Projects/jupyter_bug/ENV/lib/python3.7/site-packages/IPython/terminal/interactiveshell.py", line 20, in <module>
from prompt_toolkit.formatted_text import PygmentsTokens
ModuleNotFoundError: No module named 'prompt_toolkit.formatted_text'
[W 13:39:58.759 NotebookApp] KernelRestarter: restart failed
[W 13:39:58.760 NotebookApp] Kernel d6c405e3-6b72-4be9-93fd-f44aecc78576 died, removing from map.
Originally seen on an Ubuntu 18.04 machine using Python 3.7 and recreated on Mac OS Sierra and High Sierra with 3.7, as well as Ubuntu 16.04 with 2.7 and then 3.6. Four separate machines.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 43
- Comments: 36 (3 by maintainers)
Commits related to this issue
- Added docker hack to JN working (https://github.com/jupyter/notebook/issues/4050) — committed to mstefferson/Canopy by mstefferson 6 years ago
- Fix problem with TensorFlow and cupy tests (#1568) - when tensorflow-gpu v1.15.0 is installed in the conda environment some strange dependency leads to `ModuleNotFoundError: No module named 'pr... — committed to NVIDIA/DALI by JanuszL 5 years ago
- Fix problem with TensorFlow and cupy tests (#1568) - when tensorflow-gpu v1.15.0 is installed in the conda environment some strange dependency leads to `ModuleNotFoundError: No module named 'pr... — committed to NVIDIA/DALI by JanuszL 5 years ago
As a temporary workaround, this will fix it:
pip install 'ipykernel<5.0.0'
The
jupyter-console
master also supportsprompt-toolkit>2
, so instead of downgradingipython
, upgradingjupyter-console
should work als well (tested it in a fresh conda env after theipython 7.0
release). So the other temporary workaround (untill the next version ofjupyter-console
is on PyPi), that will fix it is:pip install git+https://github.com/jupyter/jupyter_console
See jupyter_console #167, for updates on the release.
Hi
pip install -U jupyter_console
helped me out.
I confirm below works for me at the moment (
ipykernel<5.0.0
alone was not enough):pip install ipython==7 prompt-toolkit==2.0.10 jupyter-console==6.0.0
worked for mesince there is a new release of
jupyter_console
the following command should fix the problem if its allready there and if not it shouldn’t appear anymore:pip install -U jupyter_console
@KTM-300 does your system know about pip (doespip --version
work)? If not you can add the path of your python installation to the PATH variable.Confirmed that
pip install -U jupyter_console
fixes this.In particular, this problem started happening in my environment with prompt-toolkit-1.0.15. For what it’s worth, my environment initially had prompt-toolkit-2.0.5, but then an install of
py2neo
into my environment forced a downgrade of prompt-toolkit to 1.0.15.So, this may happen if the installation of a new package sneaks in a downgrade of
prompt-toolkit
down to 1.x.pip install -U jupyter_console
+1
Thank you, this fixed my problem also. I was able to open up notebooks but the cells would not run.
Have been trying to fix for hours. Thank you,
Hey it’s worked for me too. it’s saved my day. thanks
@kevin-bates This worked for me indeed:
pip install prompt_toolkit --force-reinstall
Thanks!
pip install ipykernel
And sometimes some package forces the old
prompt_toolkit
version on you, as is the case withwandb
at the moment: https://github.com/wandb/client/issues/1498pip install -U jupyter_console is working properly
Worked for me
This worked for me. Thanks!
Thanks @gronki
conda install ipykernel’<5.0.0’ ipython’<7.0.0’ worked for me. like you, just ipykernel’<5.0.0’ wasn’t enough.
This fixed the problem for me such that the Kernel would start and I could use my notebook.