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

Time:07-30

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.

CodePudding user response:

Before trying the pip install typing (which it worked with the requests 2.19.1 version) I tried downgrading the requests module version to 2.12.1 and worked without the need to install typing.

But also barissonmez answer worked!

CodePudding user response:

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