1 min read

Notes on maintaining Python on my systems

A few notes on how I manage Python on my development machines
Notes on maintaining Python on my systems
Python logo on a white background

This is a reference blog post about my struggles with maintaining Python versions across my machines.

Note: some of the commands install specific versions that might be out of date by the time of this writing

asdf, mise, Conda, or Poetry. What option is right for you?

Conda (my preferred method)

Platform agnostic

Python

The latest Python is included when installing Miniconda

Conda Forge

Use the Conda Forge channel to access a more comprehensive library of packages, including the ones from HuggingFace, which are frequently used on big-name models

conda config --add channels conda-forge

macOS

Pytorch

Use the nightly channels if you have a machine with the latest M series processors.

conda install pytorch-nightly::pytorch torchvision torchaudio -c pytorch-nightly

This is from Apple's Developer website.

Windows

Pytorch

If you plan to use CUDA, make sure to download the CUDA Toolkit from Nvidia

Make sure to use the latest PyTorch version with the latest CUDA Toolkit

conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

Poetry

This is my favorite way of working with larger Python projects, as the onboarding experience is slightly faster when you're "dipping your toes" into Python.

You can use Conda to manage Poetry projects, but the Project website recommends pipx
I usually follow the installation steps from their documentation.

macOS

Pytorch

Like Conda, use the Nightlies on the latest M series machines

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

Windows

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121

Mise and asdf

Since both options manage Python versions across your system, you can use Poetry or Conda behind these. A few notes:

  1. Ensure your .bash_profile or .zshrc files have ordered evals first; you should eval Mise or asdf, and then Conda or pipx.
  2. .tool-versions should always match what your Poetry toml config file says.