Python Environment Tools
A brief overview of various environment tools available for Python.
Manage Python Version
Windows Store
Windows Store offers multiple versions of Python.
Homebrew
Homebrew can install multiple versions of Python, e.g.
brew install python@3.12
warning
Homebrew pythons exists to serve other formulas. Always use virtual environment and do not install other packages into Homebrew Python.
pyenv
- Install and managed multiple versions of Python on the same machine.
- Control python version in global, local, and shell levels.
- 👍🏻 Written in shell script, does not require pre-existed Python installation.
- 👎🏻 Use shims to inject the correct Python version into your shell.
Virtual Environment
venv
- Standard library module for creating lightweight virtual environments.
- Built-in module in Python 3.3 and later.
python3 -m venv path-to-env
tip
Think about where you'd like to store your virtual environments.
Directory | Path | Pros | Cons |
---|---|---|---|
Project directory | ./venv | Straightforward and easy to manage. | - Should be added to .gitignore - Bloated project directory |
User directory | ~/.virtualenvs | Manage virtual environments in one place | - May pile up over time - Easy to forget to delete after project completion |
virtualenv
- The predecessor of
venv
. - Now offers as a more feature-rich edition of
venv
. - Use
virtualenv
if you need to...- Faster environment setup.
- More control over the environment.
Manage Project Dependencies
TODO