Installing Python with uv

basics
setup
python
Author

Walter Wiggins

Published

February 26, 2025

In this post, we’ll cover a new-ish command line tool called uv that serves as both a Python package manager and project management tool. We’ll utilize this to install Python and set up an example coding project.

uv documentation page:

Python

Python is an interpreted programming language, sometimes referred to as a scripting language. It has been referred to as the lingua franca of AI and ML, so this is the language I use for all my interactive sessions and tutorials. The base Python installation comes with a number of packages for basic operations one might want to do when coding in Python. One of those packages is pip which is a package manager. This allows you to install other packages built for specific tasks. For example, you may want to install numpy so you can do numerical computing with arrays, or pandas so you can work with tabular data, or pytorch so you can do deep learning.

uv for Package Management

uv is a faster package manager that also comes with other features to assist with project management. One such feature is virtual environment management. Having a virtual environment or “env” allows you to install packages specific to a project. Different projects (or tutorials) may require different versions of the same packages, or even a different version of Python itself. Installing those packages in an env helps you avoid conflicts between packages/versions in your base Python installation.

Version Control

Another project management feature of uv is a tool called git for version control of coding projects. You can learn more about it at the link below. For now, you can think of it as a way to keep track of changes you make in your code, so that you can more easily revert to an earlier version if you make a change that breaks something. git also helps with managing collaborative development projects.

Missing Semester: git (Version Control)

To learn more about git, check out this lecture from MIT’s The Missing Semester of your CS Education course: git (Version Control).

Installation

Open up your terminal application, then copy and paste the following code into the terminal window to install uv on your system.

wget -qO- https://astral.sh/uv/install.sh | sh

Alternatively, if you’ve installed Homebrew on your system, you can copy and paste the following command into your terminal window to install uv.

brew install uv

It is wise to periodically update the libraries you have installed on your system. If you used the first command to install uv, then you may update the library with the following command.

uv self update

Otherwise, you may update uv with pip after you’ve installed Python.

Important

You must install Python before you run the following command.

pip install --upgrade uv

Installing Python with uv

Now that uv is installed, you are able to install a base version of Python to use regardless of whether you’ve setup a virtual environment for a given project.

If you have a recent model of Mac, then Python is likely already installed on your system. Run the following command in your terminal to see if Python is already installed and, if so, which version.

python --version

You can use uv to manage previously installed Python versions. Run the following command if you’d like to use and update the existing version of Python.

uv python install --reinstall

If you do not yet have Python installed, run the following command to install it with uv.

uv python install

With that, you should have a working base installation of Python, so any time you create a virtual environment with uv, it will include that base version by default unless you specify a version of Python to use.

In the next post, we’ll setup a virtual environment and install Pytorch – one of the leading libraries for deep learning.