Python
Tips and tricks for working with Python
While pyenv and pipx can still be used, uv is quickly becoming the standard/favorite for many.
I've kept the guides for these tools below, but strongly suggest checking out uv instead!
Overview
As Python gets updated, older code will cease to run due to changes in Python syntax and functionality
To resolve this, we can run code in containers, but that adds a level of complexity
uv only supports Python v3+ so use pyenv if you need Python v2.x
Installation
brew install uvView Available Python Versions
List all available python versions (both installed and not)
uv python list List only installed python versions
uv python list --only-installedList only python versions not already installed
Using Specific Python Versions
Install one or more versions of python
Install a tool with a specific python version
Set up a Virtual Environment
Creates a virtual environment with python v3.14.0
Installing Required Modules
Managing Tools Installed with uv
uvList installed tools
Install tools
This works just like
pipxorpip
Uninstall tools
Old β Examples
Old β Install and Run a Python App with a Specific Python Version
PrincipalMapper (pmapper) is a tool that requires Python version 3.9 to run (it errors out otherwise)
Old β Set up a Python Virtual Environment
We can set up a virtual environment to run any version of Python we want
This is useful for isolating your Python code/packages without impacting your system configuration
Parsing JSON
View installed modules
View pip modules
Old β Pyenv
Installation
pyenv is a useful tool for letting us quickly download and switch between multiple versions of Python
Full installation instructions can be found here
Useful commands
Old β Pipx
Installation
pipx is a useful tool for installing and running python code and apps in isolated virtual environments
Full installation instructions can be found here
Useful commands
Last updated
Was this helpful?