Python

Tips and tricks for working with Python

circle-exclamation

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

  • Another solution is to use uv (or pyenv and pipx) and run the code in virtualized environments with the required version of Python

triangle-exclamation

Installation

brew install uv

View Available Python Versions

List all available python versions (both installed and not)

uv python list 

List only installed python versions

uv python list --only-installed

List 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

List installed tools

Install tools

  • This works just like pipx or pip

Uninstall tools



Old β€” Examples

Old β€” Install and Run a Python App with a Specific Python Version

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

Useful commands


Old β€” Pipx

Installation

Useful commands

Last updated