Search code examples
python-3.xpython-requestsimporterrorpython-3.4python-pipelines

Python 3.4 ImportError: No module named 'typing' when importing requests


I've been trying to install different versions compatible for the request module for Python 3.4 (I know the python version is outdated, but is the one available for the OS I'm currently using.)

Using the pip install requests==2.19.1 command worked without any problems.

The problem actually occurs when importing the requests module in the python shell. (also in a python script, the error appears)

The line I execute:

>>> import requests

The error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\user\project\lib\site-packages\requests\__init__.py", line 112, in <modu
le>
    from . import utils
  File "D:\user\project\lib\site-packages\requests\utils.py", line 24, in <module>
    from . import certs
  File "D:\user\project\lib\site-packages\requests\certs.py", line 15, in <module>
    from certifi import where
  File "D:\user\project\lib\site-packages\certifi\__init__.py", line 1, in <module>

    from .core import contents, where
  File "D:\user\project\lib\site-packages\certifi\core.py", line 9, in <module>
    from typing import Union
ImportError: No module named 'typing'

I checked that I'm using the same environment where the request package was installed.


Solution

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

    pip install typing