Category Archives: Python

Installing Python request module on Windows

Assume you had a script that started as follows:

#!/usr/bin/python

import requests
from requests.auth import HTTPBasicAuth

If you have a bare bones Python install on Windows and you attempt to run this script, you will run into the following error:

ImportError: No module named requests

What do need to do is install the Python module called “requests”. To this do, please follow these steps, assuming you have Python 2.7:

1. Download the Python request module, requests-2.7.0.tar.gz (md5).
2. Use a 7zip or similar to fully extract the package to request-2.7.0.

If you are using Windows recommended downloads location, the extracted package will be in

C:\Users\[username]\Downloads\requests-2.7.0.tar\dist\requests-2.7.0\requests-2.7.0

3. Launch a command prompt and navigate to c:\python27\scripts.
4. Type the following command at the prompt:

pip install C:\Users\[username]\Downloads\requests-2.7.0.tar\dist\requests-2.7.0\requests-2.7.0

If successful, you should see the following messages at the command prompt:

Processing c:\users\knji\downloads\requests-2.7.0.tar\dist\requests-2.7.0\requests-2.7.0
Installing collected packages: requests
Running setup.py install for requests
Successfully installed requests-2.7.0

5. Now, if you run your original Python script, it should no longer complain about not being able to import the request module.