Pip command line "ImportError: No Module Named Typing"

Viewed 91685

Running the following command gives me the following error:

pip install pygame

Error Stack:

Traceback (most recent call last):
  File "C:\Python34\lib\runpy.py", line 171, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python34\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Python34\Scripts\pip.exe\__main__.py", line 5, in <module>
  File "C:\Python34\lib\site-packages\pip\__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named 'typing'
9 Answers

Running this line in a Mac terminal fixed it for me:

/usr/local/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip

I had the same issue. I also first tried the pip3 install pygame which was previously mentioned, before running this line. You may have to do that first. For the individual who said to try

pip install typing

that line of code will simply produce the same error. To fix it, you have to use to the aforementioned command(s).

I also ran into the same problem, because I made the foolish mistake of upgrading pip as suggested by Python.

I fixed this by downloading get_pip.py for python3.4 at https://bootstrap.pypa.io/pip/3.4/get-pip.py and running it:

python get_pip.py

It will automatically download the latest compatible version of pip (19.1.1 in this case).

Try to:

  1. wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
  2. python get-pip.py

Do the following:

sudo apt update
sudo apt-get upgrade

If there is a problem, do:

sudo apt --fix-broken install
sudo apt-get upgrade

If there is still a problem, remove and recreate your venv. And Reinstall your requirements:

rm -rf venv
python3.9 -m venv venv
. venv/bin/activate
pip install -r requirements.txt

I encountered the same error on Ubuntu 20.04 when using python3.9, I tried to run sudo apt update && sudo apt upgrade.

The output advised me to run sudo apt --fix-broken install, which had solved my problem and python3.9 is running fine now.

I have also met this problem. Any command that starts with pip have the same error, ImportError: No module named 'typing'.

Finally, python -m pip install typing solved it.

I had this error using pip because my Ubuntu installation with Python 2.7 and Python 3.5 were crossed using the versions and pip.

My solution was to uninstall Python 2.7 and pip 2.7. I also uninstalled Python 3.5 and pip 3.

I then installed Python 3.7 using these directions: Installing the latest Python 3.7 on Ubuntu 16.04 and 18.04

I'm not sure if uninstalling 3.5 and adding 3.7 is necessary. You may just be able to remove 2.7 and be good, but this is what worked for me.

Try this one:

pip3 install pygame

It looks like you are importing from the package 'typing' but you do not have it installed. Try installing the package:

pip install typing
Related