logo
Free, Micro AI Code Reviews That Run on Git Commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt git-lrc - Free, Micro AI Code Reviews That Run on Git Commit | Product Hunt

Virtualenv - Python Virtual Environment Manager

Manage Python virtual environments with ease using Virtualenv. Create, activate, deactivate, and delete environments effortlessly. Learn how to use Virtualenv and Virtualenvwrapper for efficient Python project management.

Virtualenv

Virtualenv is a tool to create isolated Python environments. This is essential for managing dependencies and avoiding conflicts between different projects.

Basic Usage

# Create a new environment:
virtualenv /path/to/project/env_name

# Create a new environment and inherit system packages:
virtualenv --system-site-packages /path/to/project/env_name

# Create a new environment with a specific Python interpreter:
virtualenv /path/to/project/env_name -p /usr/bin/python3.9

# Activate the environment:
source /path/to/project/env_name/bin/activate

# Deactivate the environment:
deactivate

Using Virtualenvwrapper

Virtualenvwrapper enhances Virtualenv by providing convenient commands for managing multiple environments.

# Install Virtualenvwrapper:
pip install --user virtualenvwrapper

# Configure Virtualenvwrapper (add to your shell configuration, e.g., ~/.bashrc):
export WORKON_HOME=~/.virtualenvs
mkdir -p $WORKON_HOME
source ~/.local/bin/virtualenvwrapper.sh

# Create a new environment:
mkvirtualenv env_name

# Activate an environment:
workon env_name

# Deactivate an environment:
deactivate

# Delete an environment:
rmvirtualenv env_name

Further Resources

See Also