Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip command line "ImportError: No Module Named Typing"

Tags:

python

pip

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'
like image 897
Rydex Avatar asked Apr 27 '21 06:04

Rydex


People also ask

What is typing module in Python?

Introduced since Python 3.5, Python's typing module attempts to provide a way of hinting types to help static type checkers and linters accurately predict errors.

Does Python install PIP?

PIP is automatically installed with Python 2.7.9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments.


Video Answer


5 Answers

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

/usr/local/opt/[email protected]/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).

like image 94
gatorcoder Avatar answered Oct 23 '22 00:10

gatorcoder


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).

like image 39
toti08 Avatar answered Oct 23 '22 00:10

toti08


Try to:

  1. wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
  2. python get-pip.py
like image 8
Hj Fg Avatar answered Oct 23 '22 02:10

Hj Fg


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
like image 8
ADf Avatar answered Oct 23 '22 00:10

ADf


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.

like image 1
ustni_voda Avatar answered Oct 23 '22 02:10

ustni_voda