Environment Management

DevOpsPython EnvironmentsFree Lesson

Advertisement

Introduction

Manage Python environments and dependencies for reproducible projects.

Virtual Environments

# Create virtual environment
python -m venv venv

# Activate
source venv/bin/activate  # Linux/Mac
venv\Scripts\activate  # Windows

# Install packages
pip install package_name

# Save dependencies
pip freeze > requirements.txt

# Install from requirements
pip install -r requirements.txt

Pipenv

# Create environment
pipenv install requests

# Activate shell
pipenv shell

# Lock and sync
pipenv lock
pipenv sync

# Remove environment
pipenv --rm

Poetry

# Create project
poetry new project_name

# Add dependencies
poetry add requests

# Install all
poetry install

# Generate lock file
poetry lock

Practice Problems

  1. Create and manage virtual environments
  2. Use requirements.txt effectively
  3. Choose between pipenv and poetry
  4. Handle multiple Python versions
  5. Share reproducible environments

Advertisement

Need Expert Python Help?

Get personalized tutoring, project support, or professional consulting.

Advertisement