Real Python
  • Start Here
  • Learn Python
    Python Tutorials →
    In-depth articles and video courses
    Learning Paths →
    Guided study plans for accelerated learning
    Quizzes & Exercises →
    Check your learning progress
    Browse Topics →
    Focus on a specific area or skill level
    Community Chat →
    Learn with other Pythonistas
    Office Hours →
    Live Q&A calls with Python experts
    Podcast →
    Hear what’s new in the world of Python
    Books →
    Round out your knowledge and learn offline
    Reference →
    Concise definitions for common Python terms
    Code Mentor →Beta
    Personalized code assistance & learning tools
    Unlock All Content →
  • More
    Learner Stories Python Newsletter Python Job Board Meet the Team Become a Tutorial Writer Become a Video Instructor
  • Search
/
  • Join
  • Sign‑In

— FREE Email Series —

🐍 Python Tricks 💌

Python Tricks Dictionary Merge

🔒 No spam. Unsubscribe any time.

Browse Topics Guided Learning Paths
Basics Intermediate Advanced
ai algorithms api best-practices career community databases data-science data-structures data-viz devops django docker editors flask front-end gamedev gui machine-learning news numpy projects python stdlib testing tools web-dev web-scraping

Table of Contents

  • How Can You Work With a Python Virtual Environment?
    • Create It
    • Activate It
    • Install Packages Into It
    • Deactivate It
  • How Do You Enable a Venv in Your IDE?
    • Create and Activate a Virtual Environment in VS Code
    • Create and Activate a Virtual Environment in PyCharm
  • Why Do You Need Virtual Environments?
    • Avoid System Pollution
    • Sidestep Dependency Conflicts
    • Minimize Reproducibility Issues
    • Dodge Installation Privilege Lockouts
  • What Is a Python Virtual Environment?
    • A Folder Structure
    • An Isolated Python Installation
  • How Does a Virtual Environment Work?
    • It Copies Structure and Files
    • It Adapts the Prefix-Finding Process
    • It Links Back to Your Standard Library
    • It Modifies Your PYTHONPATH
    • It Changes Your Shell PATH Variable on Activation
    • It Runs From Anywhere With Absolute Paths
  • How Can You Customize a Virtual Environment?
    • Change the Command Prompt
    • Overwrite Existing Environments
    • Create Multiple Virtual Environments at Once
    • Update the Core Dependencies
    • Avoid Installing pip
    • Include the System Site-Packages
    • Copy or Link Your Executables
    • Upgrade Your Python to Match the System Python
  • What Other Popular Options Exist, Aside From venv?
    • The Virtualenv Project
    • The Conda Package and Environment Manager
  • How Can You Manage Your Virtual Environments?
    • Decide Where to Create Your Environment Folders
    • Treat Them as Disposables
    • Pin Your Dependencies
    • Avoid Virtual Environments in Production
    • Use Third-Party Tools
  • Conclusion
  • Frequently Asked Questions

Recommended Video Course
Working With Python Virtual Environments