How to fix Python ImportError: No module named 'typing'

Python gives you the ImportError: No module named 'typing' message when the typing module is not found in Python or it’s not installed.

To fix this error, you need to make the typing module available. Let’s see how in this article.

The typing module provides runtime support for type hints. It’s a built-in module in Python 3.5 and later versions, but not included in earlier versions of Python.

When you run import typing or install a package that requires the typing module, you’ll see the following error:

Traceback (most recent call last):
    from typing import List, Optional
ImportError: No module named typing

To fix this error, you can either upgrade your Python version or install the stand-alone typing package from pip.

To install the stand-alone typing package, run one of the following pip install commands:

# Use pip to install typing
pip install typing

# Or pip3
pip3 install typing

# For Windows
py install typing

# If pip isn't available in PATH
python -m pip install typing

# Or with python3
python3 -m pip install typing

# For Windows without pip in PATH
py -m pip install typing

# for Anaconda
conda install -c anaconda typing

# for Jupyter Notebook
!pip install typing

# If you see permission denied error
pip install typing --user

Once you installed the typing package, the ImportError message should disappear.

If that doesn’t work, then you can try to upgrade your pip version before installing again.

Use the one of the following commands to upgrade pip:

# if pip available from command line
pip install --upgrade pip

# for pip3
pip3 install --upgrade pip

# if pip not available from command line
python -m pip install --upgrade pip

# python3
python3 -m pip install --upgrade pip

# Windows
py -m pip install --upgrade pip

Alternatively, you can download the file manually from the website:

Once you downloaded the file, open the terminal at the location where you have the downloaded script.

You need to run one of the commands below:

# For Linux / macOS

# using python3

# For Windows

After installing the right pip version, continue with installing the typing package if you have Python version less than 3.5.

Once you have the typing package, this error would be resolved.

Take your skills to the next level ⚡️

I'm sending out an occasional email with the latest tutorials on programming, web development, and statistics. Drop your email in the box below and I'll send new stuff straight into your inbox!

No spam. Unsubscribe anytime.