Skip to content

Instantly share code, notes, and snippets.

@dinhanhx
Created March 1, 2024 04:31
Show Gist options
  • Select an option

  • Save dinhanhx/21e24ff0bebbbab5b83129ea2c663777 to your computer and use it in GitHub Desktop.

Select an option

Save dinhanhx/21e24ff0bebbbab5b83129ea2c663777 to your computer and use it in GitHub Desktop.
Python Virtual Environment Tools

Python Virtual Environment Tools

This document provides some fundamental and comparisons about virtual environment tools. The readers are expected to use one of similar tools once. If not, the readers should read 12. Virtual Environments and Packages — Python 3.12.2 documentation. Some concepts might be oversimplified.

The fundamental

Every beginner tutorial about creating virtual environment starts with venv or virtualenv .

venv is a standard module for creating lightweight environment.

virtualenv is a tool to create isolated environments. Since Python 3.3, a subset of it has been integrated into the standard library under the venv module.

Eventually, the developers build management tools.

virtualenvwrapper is a useful set of scripts for creating and deleting virtual environments.

pyenv is a tool to install, isolate, manage, Python versions per user and per project.

pyenv-virtualenv is a plugin of pyenv to manage virtualenv .

pipenv is a Python virtualenv management tool that supports a multitude of systems and nicely bridges the gaps between pip, python (using system python, pyenv or asdf) and virtualenv.

The combinations

Black: virtual environment creation tools

Red: virtual environment management tools

Green: Python versions management tools

the combinations

Here are some of the tool sets that people commonly use.

The comparisons

virtualenvwrapper pipenv pyenv pyenv pyenv-virtualenv
Manage multiple Python versions No Yes Yes
Manage per project No, you can have many venv per project and many projects per venv Yes No, like virtualenvwrapper.

The holdup

The readers may ask what conda / mamaba and poetry are all about.

Conda-related

conda is a system-level, binary package and environment manager running on all major operating systems and platforms.

mamba is conda implemented in c++.

Many people might be more familiar with miniconda , micromamba which are minimal CLI versions of aforementioned tools.

Conda is similar to pyenv pyenv-virtualenv but not limited to Python. One can install C++ packages such as Nvidia drivers.

Important use case: people often use this for machine learning projects.

Poetry

poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution. Poetry either uses your configured virtualenvs or creates its own to always be isolated from your system.

Reading list

python - What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc? - Stack Overflow

Python Virtual Environments: A Primer – Real Python

References

venv — Creation of virtual environments — Python 3.12.2 documentation

virtualenv (pypa.io)

virtualenvwrapper 6.0.1.dev12+gb1aa495 — virtualenvwrapper 6.0.1.dev12+gb1aa495 documentation

https://github.com/pyenv/pyenv

https://github.com/pyenv/pyenv-virtualenv

https://github.com/pypa/pipenv

Miniconda — Anaconda documentation

Micromamba Installation — documentation

Introduction | Documentation | Poetry - Python dependency management and packaging made easy (python-poetry.org)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment