Home

virtualenv

Virtualenv is a software tool used to create isolated Python environments. Each environment has its own independent Python interpreter and a separate set of installed packages, which helps prevent dependency conflicts between projects and enables reproducible deployments. Virtualenv has historically supported multiple Python versions and both Python 2 and Python 3, which contributed to its broad adoption.

How it works: Running virtualenv <env> creates a new directory containing a Python executable and a local

Usage: Virtualenv can be installed via a package installer, commonly pip install virtualenv. To create an environment,

Key options include selecting the Python interpreter with -p or --python to point to a specific python

site-packages
directory.
Activating
the
environment
adjusts
the
shell’s
PATH
and
related
variables
so
that
commands
such
as
python
and
pip
operate
within
that
environment.
This
isolation
allows
project-specific
packages
to
be
installed
without
affecting
the
system
Python.
The
activation
script
differs
by
platform:
on
Unix-like
systems
it
is
sourced
from
env/bin/activate,
while
on
Windows
it
is
typically
env\Scripts\activate.bat
or,
for
PowerShell,
a
corresponding
script.
use
virtualenv
myenv.
Activate
the
environment
with
source
myenv/bin/activate
on
Unix-like
systems
or
myenv\Scripts\activate
on
Windows.
After
activation,
packages
can
be
installed
with
pip,
and
separate
requirements
for
the
project
can
be
captured
with
pip
freeze.
Deactivate
returns
you
to
the
global
Python
environment.
executable,
or
enabling
access
to
the
system-wide
site-packages
with
--system-site-packages.
While
Python’s
standard
library
provides
a
module
called
venv
for
creating
environments,
virtualenv
remains
a
widely
used
alternative
due
to
its
broader
compatibility
and
flexible
options.