How to Install Python and Requests for Beginners
Starting your journey into automated data collection requires a reliable technical foundation. This guide walks absolute beginners through downloading, installing, and verifying Python alongside the essential Requests HTTP library. Designed as a foundational entry point for The Complete Guide to Python Web Scraping, you will learn OS-specific installation steps, command-line verification, and how to execute your first programmatic web request without encountering common setup errors.
1. Understanding System Requirements
Before installation, ensure your operating system (Windows 10/11, macOS 11+, or Ubuntu/Debian Linux) meets the minimum requirements for Python 3.10+. You will need administrative privileges to modify system environment variables and access to a terminal or command prompt. Proper environment configuration is the first critical step in Setting Up Your Python Scraping Environment.
2. Installing Python on Your Operating System
Download the official installer from python.org. On Windows, check the Add Python to PATH box during setup to avoid command recognition issues. macOS users can use the official .pkg installer or Homebrew (brew install python3). Linux users should rely on their distribution's package managers (sudo apt install python3 python3-pip for Debian/Ubuntu).
After installation, verify success by running the version check in your terminal:
python --version
# Output: Python 3.11.4
(Note: On macOS/Linux, you may need to use python3 --version depending on your system configuration.)
3. Installing the Requests Library via pip
Python's built-in package manager, pip, handles third-party libraries efficiently. Open your terminal and execute the installation command:
pip install requests
# Output: Successfully installed requests-2.31.0 certifi-2023.7.22 charset-normalizer-3.2.0 idna-3.4 urllib3-2.0.4
(On macOS/Linux, use pip3 install requests if your system defaults to Python 2.) Pip automatically resolves and installs required dependencies like urllib3, certifi, and charset-normalizer. Wait for the Successfully installed confirmation message before proceeding to script execution.
4. Verifying Installation and Running a Test Script
Create a file named test_requests.py in your working directory and import the library. Execute a simple GET request to a public testing endpoint like httpbin.org. If the script returns a 200 OK status code and prints the response text, your environment is fully operational and ready for advanced data extraction workflows.
import requests
response = requests.get('https://httpbin.org/get')
print(f'Status Code: {response.status_code}')
print('Connection successful!')
Run the script using python test_requests.py (or python3 test_requests.py). A successful execution confirms that both Python and the Requests library are correctly installed and communicating with external servers.
Common Installation Mistakes and Fixes
| Mistake | Solution |
|---|---|
| Skipping the 'Add Python to PATH' checkbox on Windows | Re-run the installer, select Modify, and ensure Add Python to PATH is checked. Alternatively, manually add the Python installation directory to your system's Environment Variables via Control Panel. |
Using pip instead of pip3 on macOS/Linux | Modern Unix systems often separate Python 2 and 3. Use pip3 install requests and python3 script.py to target the correct interpreter version and avoid legacy conflicts. |
| Installing packages globally without a virtual environment | Always use python -m venv venv followed by source venv/bin/activate (or venv\Scripts\activate on Windows) before running pip. This prevents dependency conflicts across different scraping projects. |
Frequently Asked Questions
Do I need to install Python before using the Requests library?
Yes. Requests is a third-party Python package that requires a working Python interpreter and the pip package manager to function. You cannot run it as a standalone executable.
Why does pip install requests fail with a permission error?
This usually happens when attempting to install globally without administrative rights. Use a virtual environment, or run the command with the --user flag (pip install --user requests) to install it in your local user directory.
How do I update the Requests library to the latest version?
Run pip install --upgrade requests in your terminal. Pip will query the Python Package Index (PyPI) and replace the outdated version with the newest stable release.
Can I use Requests for scraping dynamic JavaScript websites? Requests only fetches static HTML. For sites that load content dynamically via JavaScript, you will need to pair it with a headless browser like Playwright or Selenium after mastering basic HTTP requests.