Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons

© 2026 BraveProgrammer. All rights reserved.

  1. Courses
  2. /
  3. Python Fundamentals

Lesson 35 of 55 · Python

Virtual Environments and pip

Duration: 20 minutes

Virtual Environments and pip\n\nA virtual environment isolates a project's Python interpreter and its third‑party packages, preventing version conflicts across projects.\n\nbash\n# Create a virtual environment named .venv\npython -m venv .venv\n\n# Activate (Linux/macOS)\nsource .venv/bin/activate\n\n# Activate (Windows)\n.\\venv\\Scripts\\activate\n\n# Upgrade pip inside the env\npip install --upgrade pip\n\n# Install a library, e.g., requests\npip install requests\n\n# Freeze exact versions for reproducibility\npip freeze > requirements.txt\n\n\nWhenever you start work on the project, activate the environment first. Deactivate with the deactivate command or simply close the terminal.\n

Previous: LoggingNext: Packaging and Distribution