Info Sharing Blog

Tuesday, September 1, 2020

[Fix] Python pip install/ImportError

September 01, 2020 Posted by jaacostan ,

Ok, I was trying to run a python script which is written in version 2 and while executing, i am getting the error "ImportError: No module named requests". Which means the python script is calling to import the module named requests. This particular module doesn't comes inbuilt with the python installation. So i tried to install the module in my system. Since the script is in version python 2, i need to import the module for python 2. Unfortunately, the normal pip command seems deprecated (Python2 is End of Life as well) and spend some time to find the exact command. 

Here is the way to fix. 

root@kali:~/Desktop# sudo apt-get install python-pip python-dev build-essential

This will download all the essential files. Then run the command to install your desired module. In my case "requests".

root@kali:~/Desktop# pip install requests

For Python version 3, this is very easy and straight forward. No need to run the first command if your are running only python3.

root@kali:~/Desktop# pip3 install requests