How 30 Days of Python Covers pip and Virtual Environments: Days 20 & 23 Explained

30 Days of Python dedicates Day 20 to pip package management and Day 23 to virtual environments, teaching learners how to install third-party packages and create isolated development environments using virtualenv.

The Asabeneh/30-Days-Of-Python repository is a widely-used open-source curriculum for learning Python from scratch. Within its structured daily lessons, the repository provides comprehensive coverage of 30 Days of Python pip and virtual environments across two specific days, ensuring learners understand both package installation and environment isolation before building larger projects.

Day 20 - Mastering pip Package Management

The curriculum dedicates Day 20 to Python package management through pip, located in 20_Day_Python_package_manager/20_python_package_manager.md. This day focuses exclusively on installing, inspecting, and utilizing external libraries.

Verifying pip Installation

The guide begins by ensuring learners can verify their pip installation before attempting to install packages.

pip --version

This command outputs the pip version and installation path, confirming the tool is available system-wide.

Installing and Inspecting Packages

According to the source material, Day 20 demonstrates installing popular data science and HTTP libraries that appear throughout later lessons.

pip install numpy
pip install pandas
pip install requests

After installation, learners use pip inspection commands to understand their environment. The pip list command displays all installed packages, while pip show provides detailed metadata about specific installations.

Generating Requirements Files

A critical skill taught on Day 20 is dependency tracking. The repository explains how to capture the exact package versions for reproducible environments.

pip freeze > requirements.txt

The curriculum also includes practical application of installed packages, specifically using requests to fetch data from URLs and APIs, demonstrating why pip-installed packages are essential for real-world Python development.

import requests

url = "https://www.w3.org/TR/PNG/iso_8859-1.txt"
resp = requests.get(url)
print(resp.status_code)   # 200

print(resp.text[:100])    # first 100 characters of the file

Day 23 - Virtual Environment Management

Day 23 transitions from global package management to isolated environments, documented in 23_Day_Virtual_environment/23_virtual_environment.md. This lesson prevents dependency conflicts by keeping project packages separate.

Installing virtualenv

Rather than using Python 3's built-in venv module, the Asabeneh/30-Days-Of-Python curriculum specifically instructs installing the virtualenv package for broader compatibility.

python -m pip install --user virtualenv

Creating and Activating Environments

The repository provides platform-specific activation commands. Creating an environment generates a local venv directory containing a clean Python interpreter.

virtualenv venv

Activation differs by operating system. For macOS and Linux:

source venv/bin/activate

For Windows PowerShell:

.\venv\Scripts\Activate.ps1

When activated, the terminal prompt changes to display (venv), indicating that subsequent pip commands will affect only this isolated environment.

Managing Isolated Dependencies

Inside an activated environment, pip list shows only packages installed locally to that project, not system-wide packages. This isolation prevents version conflicts between different projects.

The lesson reinforces the pip freeze workflow, now demonstrating how it captures only the current environment's dependencies, creating a clean requirements.txt file for sharing or deployment.

Sample Project Structure

Day 23 references sample modules in mypackage/greet.py and mypackage/arithmetics.py to demonstrate how personal code can be imported and tested within the isolated environment, bridging the gap between virtual environment setup and actual package development.

Complete Workflow Integration

Together, Days 20 and 23 establish a professional workflow for 30 Days of Python pip and virtual environments:

  1. Create isolation using virtualenv venv to prevent system pollution
  2. Activate the environment using OS-specific commands before installing packages
  3. Install dependencies with pip install while the environment is active
  4. Track requirements using pip freeze > requirements.txt for reproducibility
  5. Develop and test code using imported packages like requests, numpy, and pandas

This sequential approach ensures learners never install packages globally unless necessary, following Python best practices for dependency management.

Summary

  • Day 20 covers pip installation, package inspection (pip list, pip show), and dependency freezing (pip freeze) in 20_Day_Python_package_manager/20_python_package_manager.md
  • Day 23 teaches virtual environment creation, cross-platform activation commands, and isolated package management in 23_Day_Virtual_environment/23_virtual_environment.md
  • The curriculum uses virtualenv rather than built-in venv for broader Python version compatibility
  • Practical examples include installing requests, numpy, and pandas, then using them to fetch web data and perform calculations
  • Sample modules in mypackage/ demonstrate how to structure importable code within activated environments

Frequently Asked Questions

Which specific days cover pip and virtual environments in the curriculum?

Day 20 focuses exclusively on pip package management, while Day 23 provides a complete guide to virtual environments. According to the Asabeneh/30-Days-Of-Python source code, these are located in 20_Day_Python_package_manager/20_python_package_manager.md and 23_Day_Virtual_environment/23_virtual_environment.md respectively.

How does the repository handle virtual environment activation across different operating systems?

The 23_Day_Virtual_environment/23_virtual_environment.md file provides platform-specific activation commands: source venv/bin/activate for macOS and Linux systems, and venv\Scripts\activate for Windows command prompt or .\venv\Scripts\Activate.ps1 for PowerShell, ensuring learners can work regardless of their development machine.

What packages are used to demonstrate pip functionality on Day 20?

The repository uses numpy, pandas, and requests as primary examples. The requests library demonstration includes fetching data from https://www.w3.org/TR/PNG/iso_8859-1.txt to show how pip-installed packages enable real-world HTTP operations and API consumption.

Why does 30 Days of Python teach virtualenv instead of Python's built-in venv module?

While Python 3.3+ includes venv in the standard library, the curriculum specifically instructs learners to install virtualenv via pip install virtualenv. This approach works consistently across all Python versions (including Python 2.7 environments) and provides a uniform learning experience regardless of the learner's base Python installation.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →