“A Virtual Environment is a tool to keep the dependencies required by different projects in separate places, by creating virtual Python environments for them. It solves the “Project X depends on version 1.x but, Project Y needs 4.x” dilemma, and keeps your global site-packages directory clean and manageable.” - The Hitchhiker’s Guide to Python
In this blog post I’ll explain about virtualenv, venv, and how I use both.
virtualenv
virtualenv gives the user the ability to use virtual environments for their python 2.x and 3.x projects. It completely isolates your projects and their dependencies from each other which makes IT AWESOME and really simple to use.
venv
TL;DR virtualenv re-implemented inside python 3.6
“The venv module provides support for creating lightweight virtual environments with their own site directories, optionally isolated from system site directories. Each virtual environment has its own Python binary (allowing creation of environments with various Python versions) and can have its own independent set of installed Python packages in its site directories.” - docs.python.org
how I use it
Most of the time, I use direnv to handle my virtualenvs. It works flawlessly and completely transparent.
Otherwise, I use my own custom made functions to create venvs (I not a fan of virtualenvwrapper):
# source the virtualenv in the current directory |