Search code examples
pythonmodulepiptyping

ImportError: No module named 'typing' when trying to install a package


I want to install pygame on my PC when I type pip in cmd I get this error:

  File "C:\Python34\Scripts\pip3-script.py", line 9, in <module>
    load_entry_point('pip==21.1', 'console_scripts', 'pip3')()
  File "C:\Python34\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__
init__.py", line 558, in load_entry_point
  File "C:\Python34\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__
init__.py", line 2682, in load_entry_point
  File "C:\Python34\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__
init__.py", line 2355, in load
  File "C:\Python34\lib\site-packages\setuptools-18.1-py3.4.egg\pkg_resources\__
init__.py", line 2361, in resolve
  File "C:\Users\user\AppData\Roaming\Python\Python34\site-packages\pip\__init__
.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named 'typing'

Solution

  • If you accidentally upgraded your pip, you are unfortunately unable to use pip to restore your previous version as pip is broken.

    If you were on a Linux like Centos you maybe able to reinstall pip using this:

    yum reinstall -y python2-pip.noarch python27-python-pip.noarch
    

    But since you are using Windows, maybe try reinstall pip using https://bootstrap.pypa.io/get-pip.py and specify the pip version you want:

    https://bootstrap.pypa.io/get-pip.py