Master Python Virtual Environments with virtualenvwrapper: A Step-by-Step Guide
This tutorial walks you through why virtual environment management tools are needed, how to install virtualenvwrapper on Windows and Linux, configure system variables, and use commands such as workon, mkvirtualenv, and rmvirtualenv to list, create, activate, deactivate, and delete Python virtual environments efficiently.
In this article we continue improving a previous tutorial on Python virtual environments, focusing on a management tool to simplify handling multiple environments.
Why Use a Virtual Environment Management Tool?
Previously we learned how to set up a virtual environment, but each time we had to navigate to the environment folder and activate it manually, which becomes cumbersome when many environments exist. A management tool streamlines this process.
Installation
We use virtualenvwrapper (or virtualenvwrapper-win on Windows). Install with: pip install virtualenvwrapper-win (Windows) or pip install virtualenvwrapper (Linux).
Configuration
After installation, ensure pip is up‑to‑date by running pip list in the real environment and updating if necessary (see screenshots). Then set the WORKON_HOME environment variable to the directory where you want to store virtual environments:
Open System > Advanced system settings > Environment Variables , create a new variable named WORKON_HOME with the desired path, and save.
Basic Commands
List all virtual environments: workon Enter a virtual environment: workon <env_name> Exit the current environment: deactivate Create a new environment: mkvirtualenv <env_name> Delete an environment: rmvirtualenv <env_name> After setting WORKON_HOME, open a new command prompt and run workon to see the list of environments.
Common issues, such as the workon command not being recognized, are usually caused by missing system environment variable configuration; fixing WORKON_HOME resolves them.
Tips
Even if tab completion does not suggest commands, you can type them manually. Remember the shortcuts: mk for mkvirtualenv and rm for rmvirtualenv.
Conclusion
All essential commands for managing Python virtual environments with virtualenvwrapper have been covered. Practice these steps to become proficient in handling multiple environments efficiently.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Python Crawling & Data Mining
Life's short, I code in Python. This channel shares Python web crawling, data mining, analysis, processing, visualization, automated testing, DevOps, big data, AI, cloud computing, machine learning tools, resources, news, technical articles, tutorial videos and learning materials. Join us!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
