Python Virtual Environment

Overview

Virtualenv tool helps to create isolated Python Environment. Different projects might require different versions of packages and using virtualenv helps to create that isolation.

Installing Virtual Environment

pip install virtualenv

Creating Virtual Environment

virtualenv appName

# Inheriting System Site Packages
virtualenv venv --system-site-packages

Activating Virtual Environment

cd appName
source bin/activate

Basically what this command is doing is using the local, clean install of Python in your virtual environment to run your commands.

Installing Packages

pip install requests

Get Back out of the Environment

deactivate

Saving your Modules

pip freeze > requirements.txt
pip install -r requirements.txt