GeneralPancake
GeneralPancake

Reputation: 565

ipython - "cannot import name 'create_prompt_application' from 'prompt_toolkit.shortcuts'

I'm trying to get ipython working on my windows 10 64 bit computer. When I try to start ipython from the command line, I get the error pictured in the screenshot attached to this question.

Has anyone encountered this? How I might I fix this problem?

Ipython Error

Upvotes: 30

Views: 30739

Answers (11)

Scott Stensland
Scott Stensland

Reputation: 28285

For those of us who get an error

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
mssql-cli 1.0.0 requires click<7.1,>=4.1, but you have click 8.1.3 which is incompatible.
mssql-cli 1.0.0 requires prompt-toolkit<2.1.0,>=2.0.0, but you have prompt-toolkit 3.0.38 which is incompatible.

or get this error

ImportError: cannot import name 'KeyPressEvent' from 'prompt_toolkit.key_binding' (/home/olaf/.local/lib/python3.10/site-packages/prompt_toolkit/key_binding/__init__.py)
   (file "/home/olaf/.local/lib/python3.10/site-packages/IPython/terminal/shortcuts/auto_match.py", line 8, in <module>)

to avoid breaking existing python package version setup just create a new python virtual environment

pip install virtualenv                  #  install package which can create new virt environments
python -m virtualenv venv_this_example  #  create virt environment
source venv_this_example/bin/activate   #  engage virt env
pip3 install 'prompt-toolkit<2.0.0,>=1.0.15' --force-reinstall # issue python package install command which only impacts this specific virt env and not entire host box python package install ecosystem

notice in above it create new directory

venv_this_example/bin/activate

which isolates python packages installed to ONLY effecting this specific virt env

Upvotes: 0

gajananbejgamwar
gajananbejgamwar

Reputation: 53

You have to run

pip install --user ipython

to make it work if your user does not have admin rights.

Upvotes: 1

Sahithi Parsi
Sahithi Parsi

Reputation: 1

try pip install prompt-toolkit==1.0.15. works on windows

Upvotes: 0

Arzanico
Arzanico

Reputation: 141

This can also be a solution

pip3 install --upgrade ipython

if you are working with python3. Or,

pip3 install ipython

This solves some problems of missing kernel to, at least on Linux.

Upvotes: 11

Mahsa
Mahsa

Reputation: 207

worked for me: sudo -H pip install --ignore-installed -U ipython

Upvotes: 0

Bohumir Zamecnik
Bohumir Zamecnik

Reputation: 2815

In my case there was an old installation of IPython when I installed juptyer. So pip install -U ipython.

Upvotes: 2

Amir
Amir

Reputation: 141

pip install ipython worked for me:)

Upvotes: 3

Nir
Nir

Reputation: 1874

I had the same issue using conda to set virtual environment with a default python version (Python 3.6.4).

Creating the conda environment and forcing any specific python version (even the same version as the problematic default):

conda create -n test_env python=3.6.4

solved it.

Upvotes: 0

Alfredo Lopez
Alfredo Lopez

Reputation: 19

i solve the problem with this commands

sudo -H pip3 install fs

sudo -H pip3 install prompt-toolkit --force-reinstall

pip3 install prompt-toolkit --force-reinstall

Upvotes: 1

ex2tron
ex2tron

Reputation: 333

You can just reinstall the ipython, that will solve the 'prompt-toolkit' problem automatically.

pip install ipython 

Upvotes: 20

dotism
dotism

Reputation: 726

This problem is caused by having a newer version of Prompt Toolkit installed than is depended upon by IPython. (Version 2.0.4 of Prompt Toolkit is installed and IPython requires version 1.0.15.)

You can rectify this issue by installing an older, compatible version of prompt-toolkit with pip (or pip3):

pip3 install 'prompt-toolkit<2.0.0,>=1.0.15' --force-reinstall

(If you install or upgrade Prompt Toolkit past 1.0.15—the last 1.x version—you will receive a warning from pip: ipython 6.5.0 has requirement prompt-toolkit<2.0.0,>=1.0.15, but you'll have prompt-toolkit 2.0.4 which is incompatible.)

Upvotes: 48

Related Questions