← HW 0 overview

Setting Up Python with uv

CMSC 141 • HW 0, part 5 of 6

You will need an internet connection for this section.

There are many tools for managing Python (virtualenv, pip, conda, and others). In this course we use uv. It keeps everyone on the same Python version and the same libraries, which heads off a whole class of "it works on my machine" problems. It is quick to install and easy to use.

As before, the $ is the prompt. Type only what comes after it.

Installing uv

Open a terminal and run:

$ curl -LsSf https://astral.sh/uv/install.sh | sh

Then set up tab completion for your shell. On macOS (zsh):

$ echo -e "autoload -Uz compinit\ncompinit" >> ~/.zshrc
$ echo 'eval "$(uv generate-shell-completion zsh)"' >> ~/.zshrc

On Windows (WSL, bash):

$ echo 'eval "$(uv generate-shell-completion bash)"' >> ~/.bashrc

After running the echo command, close your terminal and open a new one so the changes take effect. If you use a shell other than the default, see the uv documentation.

Installing Python with uv

Install the version of Python we use in this course:

$ uv python install 3.13
Installed Python 3.13.5 in 1.24s
 + cpython-3.13.5-macos-aarch64-none (python3.13)

Your exact output depends on your platform. Check the version with:

$ uv run python -V
Python 3.13.5

If you see a version that does not start with 3.13, ask for help.