The Python Requests library is extremely useful for making HTTP requests in Python. However, if you don't have pip available to install packages, you can still access Requests by downloading the source code directly.
Downloading the Requests Source Code
The easiest way is to go to the Requests GitHub repository and click on the "Code" button to download the ZIP file containing the latest source code. Unzip this folder wherever you want to use Requests from.
Alternatively, if you have git installed, you can clone the repository:
git clone https://github.com/requests/requests.git
Using Requests Without Installation
To use Requests without pip installing, you need to access the module from the directory you downloaded/cloned it to. For example:
import sys
sys.path.append("/path/to/requests")
import requests
Then you can make requests as normal:
response = requests.get("http://www.example.com")
print(response.text)
The key things to note are:
This works fine for scripts and Jupyter notebooks. For reusable modules, encapsulate the path appending and import code in a function/class.
Considerations
While this allows using Requests without pip, some things to keep in mind:
Overall, accessing Requests like this is very useful for situations where you can't install packages normally. But using pip is recommended if available.