Skip to content
Happy Programming Guide
Start learning
Python

How to Fix ModuleNotFoundError: No Module Named ‘IPython’

IPython is missing from the interpreter you are running. Here is the fix, including the capitalisation trap and the Jupyter kernel mismatch behind most cases.

A backlit keyboard in a dark room

ModuleNotFoundError: No module named 'IPython' means IPython is not installed for the Python that is running your code. The install command is python -m pip install ipython — note the package name is lowercase while the import is capitalised, which is the first thing that catches people. The second is that the error usually comes from a Jupyter kernel pointing at a different environment.

The fix#

Terminal
python -m pip install ipython
Python
from IPython.display import display, Markdown
import IPython

print(IPython.__version__)

The python -m prefix guarantees the install lands in the interpreter you just ran. A bare pip is a separate program that may belong to a different Python entirely, which is why “I already installed it” is such a common follow-up.

The capitalisation trap#

Context Spelling
pip install ipython
import in code IPython
command line ipython

import ipython fails even when the package is correctly installed, because module names are case-sensitive. The error message quotes exactly what you asked for, so read it carefully: No module named 'ipython' with a lowercase i is a spelling mistake, not a missing package.

Where it usually comes from#

Most people never import IPython deliberately. It arrives as a dependency:

  • Jupyter notebooks — IPython is the kernel
  • IPython.display for showing images, HTML and Markdown in a notebook
  • Debuggers such as ipdb
  • Some plotting and progress-bar libraries that check for a notebook context
Python
from IPython.display import display, HTML, Image, Markdown

display(Markdown("**bold text**"))
display(Image("chart.png"))

The Jupyter kernel mismatch#

This is the real cause in most reports. A notebook runs a kernel, and that kernel is a specific Python environment — often not the one your terminal uses.

Install from inside the notebook so there is no ambiguity:

Python
import sys
!{sys.executable} -m pip install ipython

Then restart the kernel. Python caches imported modules, so a newly installed package is invisible until the kernel restarts.

To register an environment as a kernel properly:

Terminal
source .venv/bin/activate
python -m pip install ipykernel
python -m ipykernel install --user --name myproject --display-name "Python (myproject)"

The new kernel then appears in Jupyter’s kernel menu, and selecting it means the notebook uses the same environment as your terminal.

Terminal
jupyter kernelspec list      # what kernels exist and where they point

Virtual environments#

Terminal
python -m venv .venv
source .venv/bin/activate        # .venv\Scripts\activate on Windows
python -m pip install ipython jupyter

A virtual environment cannot see globally installed packages. If IPython is installed system-wide and your project uses a venv, the import fails inside the venv — correctly, and by design.

Confirming which Python you are on#

Python
import sys
print(sys.executable)
print(sys.version)
Terminal
python -m pip show ipython

Run the first inside the failing context — the notebook cell, the script, the IDE — and compare with where pip installed the package. Any difference is your answer.

Writing code that works with and without it#

If a script might run in a notebook or a terminal, do not assume IPython exists:

Python
try:
    from IPython.display import display
except ImportError:
    display = print


display("works either way")

To detect a notebook specifically:

Python
def in_notebook():
    try:
        from IPython import get_ipython
        shell = get_ipython()
        return shell is not None and shell.__class__.__name__ == "ZMQInteractiveShell"
    except ImportError:
        return False

What IPython actually gives you#

Beyond notebooks, the ipython command is a much better interactive shell than the default:

Terminal
ipython
Output
In [1]: %timeit sum(range(1000))
In [2]: %run script.py
In [3]: len?          # documentation
In [4]: len??         # source, where available
In [5]: !ls           # run a shell command
In [6]: %debug        # post-mortem debugger after an error

Tab completion, syntax highlighting, sensible multi-line editing and the magic commands above make it worth installing even if you never touch a notebook.

Questions people ask#

Do I need IPython if I use Jupyter?

You already have it — Jupyter’s Python kernel is IPython. Installing Jupyter installs it as a dependency.

Why does the import work in the terminal but not in VS Code?

VS Code selects its own interpreter. Open the command palette, run “Python: Select Interpreter”, and choose your project environment.

What is the difference between IPython and Jupyter?

IPython is the interactive shell and kernel. Jupyter is the notebook interface that talks to kernels, of which IPython is one. Jupyter grew out of the IPython project, which is why the names are entangled.

Can I use IPython magic commands in a normal script?

No. Commands starting with % or ! are IPython syntax, not Python, and a plain interpreter will raise a SyntaxError on them.

Where to go next#

Python virtual environments, and why imports keep failingRead next

Keep reading

Keep going — pick your next guide

The fastest way to improve is to read one guide, then build the thing it describes. Start with the basics, or jump straight to a project.

Ask a question or share what worked

Your email address will not be published. Required fields are marked *