Fundamentals 6 min read

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.

Python Crawling & Data Mining
Python Crawling & Data Mining
Python Crawling & Data Mining
Master Python Virtual Environments with virtualenvwrapper: A Step-by-Step Guide

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.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

DevelopmentPythonvirtual environmentpipvirtualenvwrapper
Python Crawling & Data Mining
Written by

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!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.