Managing Python Environments

Date: 27 November 2020

Category: Python

Tag: General

Reference doc for some good articles on python virtual environment tools; along with lists and links for the common version, virtual environment and package management tools.

Articles

Python Version Management

  • pyenv
  • conda - Anaconda/Miniconda
    • I initially started developing in Python using the Anaconda distribution, hence tend to use conda to manage environments

Virtual Environments

Package Management

Direnv

[direnv:https://direnv.net/]

direnv is an extension for your shell. It augments existing shells with a new feature that can load and unload environment variables depending on the current directory.

direnv can be used to activate a particular Python version/virtual environment when you cd into a directory. Thus, a virtualenv can be created for a project, which is activated each time you go into the repo.

Note that there currently isn’t a way to specify what happens when you leave the directory (e.g. deactivate the virtual environment), but there is an open issue on GitHub covering this.