importerror no module named typing

importerror no module named typing

 

I got the error ‘importerror no module named typing’ while trying to import the module in python2. Follow the below steps to fix the error.

1. Log into your Linux server via SSH

2. typing can be installed using pip

3. Run the command ‘pip install typing’

4. Import typing to confirm it is installed correctly
 

importerror no module named typing

importerror no module named typing


 
STEPS:

First check the version of Python installed on your server.
 

[root@centos /]# python2 -V
Python 2.7.18

 
The below command checks whether python-pip package is installed or not :
 

[root@centos /]# rpm -qa | grep -i pip
python2-pip-9.0.3-18.module_el8.5.0+743+cd2f5d28.noarch

 
OR
 

[root@centos /]# pip2 -V
pip 9.0.3 from /usr/lib/python2.7/site-packages (python 2.7)

 
Run the command ‘yum install python-pip’ OR ‘yum install python2-pip’ to install python-pip package on your CentOS server.

pip is the package installer for Python. To install typing using pip:
 

# pip install typing

 
Import typing to make sure it is installed correctly.
 

[root@centos /]# python2
Python 3.6.8 (default, Nov 21 2019, 19:31:34)
[GCC 8.3.1 20190507 (Red Hat 8.3.1-4)] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import typing

 
OR you can run ‘pip freeze | grep -i typing’ to confirm
 

[root@centos /]# pip2 freeze | grep -i typing
typing==3.10.0.0

 
Follow the below steps if you want to install a specific version of typing

Example :
 

#pip install typing==3.7.4.2

 
The above command will install typing version 3.7.4.2.