what’s the difference between pyenv, virtualenv, virtualenvwrapper

My first post was about Python ‘virtualenv‘ – started with what is a virtual environment, why we need it, and a minimal example.  The purpose was to clarify beginners about what they get to see in almost every Python example. After that I also wrote about pyenv, and virualenvwrapper, felt like I may have enhanced the confusion here, all the starters might be having the question – what’s the difference between pyenv, virtualenv, virtualenvwrapper ? hence the today’s post title.
As you all know already that a virtual environment is ” a separate Python interpreter with its own set of installed packages.”

1.virtualenv

is basically a separate Python interpreter with its own set of installed packages. It is the Python interpreter along with the installed packages (other than standard libraries) which make the environment – so we can have multiple Python environments on a single machine, the environments other the default are termed as virtual environment, which we need to create and activate before we can use (as demonstrated here). A note from official docs:
” A virtual environment (also called a venv) is a Python environment such that the Python interpreter, libraries and scripts installed into it are isolated from those installed in other virtual environments, and (by default) any libraries installed in a “system” Python, i.e. one which is installed as part of your operating system.”

2.pyvenv 

is same as virtualenv, it comes with Python standard distribution since version 3.4. It uses the venv module underneath.

3.virtualenvwrapper

is just a wrapper (an extension) around the virtualenv, with intent to provide a cross platform better management of venv. For more read – “Better management of Python virutal environments with virtualenvwrapper“.

4.  pyenv

(previously known as pythonbrew)- to put it simply, it’s Python version management tool. pyenv lets you have multiple Python installations i.e. multiple Python versions, from which you can set the global Python version (the default version to use), and also the local Python version i.e. project/application specific. Apart from this you can also create virtualenv – it has a separate sub-command for it.
Once installed, penv is a bash command not needing python to for execution – it’s user-level command, so no need to use sudo.
To sum up, pyenv is a superset of virtualenv. There’s a detailed post about pyenv setup and usage – ‘pyenv – managing multiple Python versions‘.

Leave a Reply

Your email address will not be published. Required fields are marked *