jupyter_console: Jupyter-console incompatible with prompt-toolkit 2.0.2

After updating the prompt-toolkit package to the version 2.0.2 I get the following error message :

jupyter-console 5.2.0 has requirement prompt-toolkit<2.0.0,>=1.0.0, but you'll have prompt-toolkit 2.0.2 which is incompatible.

Then if I start a jupyter notebook the message “kernel died” is appearing all the time with this output

[I 14:23:58.331 NotebookApp] Kernel started: 60ff14ae-6730-43b2-9c9a-5df4b549aa03
Traceback (most recent call last):
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
    from ipykernel import kernelapp as app
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
    from .connect import *
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\ipykernel\connect.py", line 13, in <module>
    from IPython.core.profiledir import ProfileDir
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\IPython\__init__.py", line 55, in <module>
    from .terminal.embed import embed
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\IPython\terminal\embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages\IPython\terminal\interactiveshell.py", line 22, in <module>
    from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout, create_output
ImportError: cannot import name 'create_prompt_application'
[I 14:24:01.294 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports

I downgraded the prompt-toolkit to the version 1.0.15 and jupyter worked again.

Python 3.6.5 jupyter 1.0.0 jupyter-client 5.2.3 jupyter-console 5.2.0 jupyter-core 4.4.0 ipython 6.4.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 123
  • Comments: 66 (22 by maintainers)

Commits related to this issue

Most upvoted comments

Oddly, it was working fine for a few weeks and suddenly today after rebooting, I got that same error. @blfuentes 's temporary solution worked perfectly. This is the command:

sudo pip install 'prompt-toolkit==1.0.15'

For me, upgrading ipython did the trick (I only installed jupyter before). (Fedora 28) pip3 install --upgrade --user ipython (--user if you’re not in a virtual environment or not on Windows)

Ok, I see. It is not a hi-priority, and this is a volunteer project. You assume that everybody knows python, knows how to hack jupyter code (and provide patches), and that the operating system is not pushing any updates.

I downgraded ipython pip install -U ipython==6.5.0

and prompt-tookit pip install -U prompt-toolkit==1.0.15

pip3 install --upgrade --force jupyter-console Worked for me

When someone gets to it. You can continue using Jupyter with prompt_toolkit 1.0.x in the meantime, so it’s not high priority.

When someone gets to it. You can continue using Jupyter with prompt_toolkit 1.0.x in the meantime, so it’s not high priority.

More especially, this is an open source project that is mostly developed by volunteers on their own time, which is one of resource we miss most. The best way to get this issue fixed is to try to create a patch and send a pull request yourself. We are happy to guide you and review your work. As said above similar work has been done on IPython (https://github.com/ipython/ipython/pull/11177) so transposing the work should not be too hard.

You can also help us by contributing to the project in other way (PR reviews, documentation, managing mailing list, social media, responding to other issues) which should free up time for more knowledgeable people to take care of complex issues.

Thanks

Jupyter end user here experiencing “ImportError: cannot import name ‘create_prompt_application’”. Argh! Should be preparing my class. Serves me right – I should have a Docker image with working jupyter, and not install it from pip every time, which makes me vulnerable to release bugs. But this appears to fix it:

pip uninstall prompt-toolkit 
pip install prompt-toolkit==1.0.15 
pip uninstall jupyter-console 
pip install jupyter-console==5.2.0 

Jupyter console needs some love. Most of the same work has been done in ipython/ipython#11177, if any of you have the time, feel free to send PRs.

When will this be fixed? Its been more than one month that this bug prevents jupyter from running.

Only to get iPython back and running What worked for me was to uninstall Jupyter since I didn’t need it at the time:

Remove this guy pip uninstall jupyter

Uninstall problematic version pip uninstall prompt_toolkit

Remove old “broken version” pip uninstall ipython

Let pip install with it’s preferred dependencies pip install ipython

pip3 install --upgrade --force jupyter-console Worked for me windows10 x64, the command worked for me too pip install --upgrade --force jupyter-console

Same issue

Prefer pip install -U ipython<7 If there is ever a new release of IPython 6.x this command will update it. Typically, unless you are freezing your dependencies, or create an App you should never pin your dependencies exactly.

@Carreau regarding your first comment in the issue: I thank all the voluntary effort that you do across the Jupyter ecosystem, and acknowledge that Jupyter devs get lots of undeserved whining from impatient users (I saw another thread where someone was using <h1> to make a point, really bad).

However, “feel free to send PRs” not only is hardly a useful explanation of what exactly needs to be done to port jupyter_console to prompt_toolkit 2.0: it also deviates the attention from the main user-facing issue, which is that people get broken installations.

jupyter_console is a package that most users do not use directly, but it gets installed when people do pip install jupyter when in fact they might just want pip install notebook. As pip does not solve dependencies (although at least now we get more informative warnings) this has the unfortunate consequence of dragging prompt-toolkit < 2 and therefore break both the notebook and ipython itself. As a result, even jupyter console itself is broken:

$ jupyter console
Traceback (most recent call last):
  File "/home/juanlu/.miniconda36/envs/propan36/bin/jupyter-console", line 7, in <module>
    from jupyter_console.app import main
  File "/home/juanlu/.miniconda36/envs/propan36/lib/python3.6/site-packages/jupyter_console/app.py", line 26, in <module>
    from jupyter_console.ptshell import ZMQTerminalInteractiveShell
  File "/home/juanlu/.miniconda36/envs/propan36/lib/python3.6/site-packages/jupyter_console/ptshell.py", line 21, in <module>
    from IPython.core import page
  File "/home/juanlu/.miniconda36/envs/propan36/lib/python3.6/site-packages/IPython/__init__.py", line 55, in <module>
    from .terminal.embed import embed
  File "/home/juanlu/.miniconda36/envs/propan36/lib/python3.6/site-packages/IPython/terminal/embed.py", line 16, in <module>
    from IPython.terminal.interactiveshell import TerminalInteractiveShell
  File "/home/juanlu/.miniconda36/envs/propan36/lib/python3.6/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'

In my opinion “jupyter_console is incompatible with IPython 7 at the moment because it’s not yet ported to prompt-toolkit 2, please upgrade prompt-toolkit and you will be able to safely use IPython and Jupyter Notebook (at the cost of breaking jupyter_console) while someone does the port.” would have been a much more useful comment. Even a hotfix of the jupyter metapackage restricting the versions would be a better temporary solution to this problem:

https://github.com/jupyter/jupyter/blob/563951c60d66118a79fa397efb410280f3ce4db7/setup.py#L26-L33

(See also https://github.com/jupyter/jupyter_console/issues/166)

Please take this as constructive criticism, I love what you folks are doing and hope that you continue to enrich this wonderful project ❤️

Same issue here. Hope it can be fixed soon.

pip3 install --upgrade --user ipython

This works for me in Ubuntu 18.04.

I’d like to point out that I googled the error message that I got whenever I tried pip install jupyter in an empty virtual environment, and the first result was this issue page. I got here without realizing that jupyter and jupyter-console are actually different things, and I believe that many people reading this may be in the same situation, so I’ll quote the comment by @Juanlu001 that saved me:

jupyter_console is a package that most users do not use directly, but it gets installed when people do pip install jupyter when in fact they might just want pip install notebook. As pip does not solve dependencies (although at least now we get more informative warnings) this has the unfortunate consequence of dragging prompt-toolkit < 2 and therefore break both the notebook and ipython itself.

All I had to do was pip install notebook instead of pip install jupyter. The command jupyter notebook still works, I still don’t know exactly what jupyter_console is, but I got a working environment again 😃

You also may need to do this: pip3 install --upgrade --user jupyter-console

@Carreau @dsblank I’m still having this issue on a fresh pip install of jupyter (ubuntu 18.04, Python 3.6.6). It shows I have jupyter_console 6.0.0 installed but I’m still having the import issue. Let me know what I can provide to help resolve this.

Yes, still seeing this error…

@Carreau @dsblank I’m still having this issue on a fresh pip install of jupyter (ubuntu 18.04, Python 3.6.6). It shows I have jupyter_console 6.0.0 installed but I’m still having the import issue. Let me know what I can provide to help resolve this.

I think I am getting a different flavor of this problem.

First attempt to install jupyterlab Based on this post, I pin the version of prompt_toolkit in my requirements.txt

prompt_toolkit==1.0.15
jupyter
jupyterlab

But when I run

pip install -r requirements.txt

I get the following

Could not find a version that matches prompt_toolkit<2.0.0,<2.1.0,==1.0.15,>=1.0.0,>=2.0.0 Tried: 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.32, 0.33, 0.33, 0.34, 0.34, 0.35, 0.35, 0.36, 0.36, 0.37, 0.37, 0.38, 0.38, 0.39, 0.39, 0.40, 0.40, 0.41, 0.41, 0.42, 0.42, 0.43, 0.43, 0.44, 0.44, 0.45, 0.45, 0.46, 0.46, 0.47, 0.47, 0.48, 0.48, 0.49, 0.49, 0.50, 0.50, 0.51, 0.51, 0.52, 0.52, 0.53, 0.53, 0.54, 0.54, 0.55, 0.55, 0.56, 0.56, 0.57, 0.57, 0.58, 0.58, 0.59, 0.59, 0.60, 0.60, 1.0.0, 1.0.0, 1.0.1, 1.0.1, 1.0.2, 1.0.2, 1.0.3, 1.0.3, 1.0.4, 1.0.4, 1.0.5, 1.0.5, 1.0.6, 1.0.6, 1.0.7, 1.0.7, 1.0.8, 1.0.8, 1.0.9, 1.0.9, 1.0.10, 1.0.10, 1.0.13, 1.0.13, 1.0.14, 1.0.14, 1.0.15, 1.0.15, 2.0.1, 2.0.1, 2.0.2, 2.0.2, 2.0.3, 2.0.3, 2.0.4, 2.0.4 There are incompatible versions in the resolved dependencies.

Second attempt to install jupyterlab When I don’t specify prompt_toolkit in requirements.txt

jupyter
jupyterlab

I get this

Could not find a version that matches prompt-toolkit<2.0.0,<2.1.0,>=1.0.0,>=2.0.0 Tried: 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.32, 0.33, 0.33, 0.34, 0.34, 0.35, 0.35, 0.36, 0.36, 0.37, 0.37, 0.38, 0.38, 0.39, 0.39, 0.40, 0.40, 0.41, 0.41, 0.42, 0.42, 0.43, 0.43, 0.44, 0.44, 0.45, 0.45, 0.46, 0.46, 0.47, 0.47, 0.48, 0.48, 0.49, 0.49, 0.50, 0.50, 0.51, 0.51, 0.52, 0.52, 0.53, 0.53, 0.54, 0.54, 0.55, 0.55, 0.56, 0.56, 0.57, 0.57, 0.58, 0.58, 0.59, 0.59, 0.60, 0.60, 1.0.0, 1.0.0, 1.0.1, 1.0.1, 1.0.2, 1.0.2, 1.0.3, 1.0.3, 1.0.4, 1.0.4, 1.0.5, 1.0.5, 1.0.6, 1.0.6, 1.0.7, 1.0.7, 1.0.8, 1.0.8, 1.0.9, 1.0.9, 1.0.10, 1.0.10, 1.0.13, 1.0.13, 1.0.14, 1.0.14, 1.0.15, 1.0.15, 2.0.1, 2.0.1, 2.0.2, 2.0.2, 2.0.3, 2.0.3, 2.0.4, 2.0.4 There are incompatible versions in the resolved dependencies.

System Specifications

python 3.7.0
pip ---> latest

Try pip install ipython --upgrade --user this works for me;)

If this hasn’t been fixed yet, may I take my hand at working on a solution?

Of course, and sorry if we can be slow to review. Feel free to ping us if necessary.

pip install ‘prompt-toolkit==1.0.15’

For Windows: pip install prompt-toolkit==1.0.15

I am getting an error ImportError: No module named 'prompt_toolkit.formatted_text' what does this mean? I need to explicitly install prompt_toolkit?? If yes, then please help with this.

I found a solution to this problem here : https://stackoverflow.com/questions/52551878/problems-upgrading-ipython-prompt-toolkit-incompatibilities

The solution for me was to pip uninstall prompt-toolkit and pip install prompt-toolkit. This uninstalled v1.0.5 and installed v2.0.4.

We did jupyter-console<5 for the time being.

Need to coordinate the release of a new jupyter-console with ipython, otherwise they each want different versions of prompt_toolkit.

If this is still an open issue, I’ll port jupyter_console to prompt-toolkit later today.

Hi future readers, per this: https://medium.com/@supachaija/how-to-fixed-modulenotfounderror-prompt-toolkit-formatted-text-on-jupyter-python-b51f2132ac1c

Using this version works (I’ve also confirmed) ipython==6.5.0

Presumably you are using an old version, but if you are just looking to get something running…

UPDATE 10/20/2018: I THINK THEY HAVE FIXED IT. Now my IPYTHON AND prompt_toolkit are both the most recent/current version and everything good. The only thing I need to downgrade (from the newest version) a little is the tensorflow because of my old machine. Thank you guys for this wonderful open source work!

@dsblank firstly thanks for your and the team’s hard work. at the moment, I’m still seeing this issue. As suggested before, running sudo pip install 'prompt-toolkit==1.0.15' fixed the problem.