I use Debian Linux; the current stable version of Debian has Python 3.11.2. At the time I write this, Python 3.13 has just been released. So I used my desire to try out the new Python as a chance to explore uv as well. My instructions here are tested on Debian Linux, but may work with modifications on other Linux-based systems like Ubuntu or Raspberry Pi OS.
What's uv, anyway?
uv is "An extremely fast Python package and project manager, written in Rust." It's on github and pypi and is also well-documented.
Among its many features, uv is capable of managing multiple versions of Python, so I decided to use it to test drive Python 3.13.
Installing uv via pipx
First, install the pipx command using the operating system package manager. (debian package name: pipx)
Then, install uv: pipx install uv
Once you've done this, you should have the uv command available. However, you may see a warning like this:
⚠️ Note: '/home/example/.local/bin' is not on your PATH environment variable.
These apps will not be globally accessible until your PATH is updated. Run
`pipx ensurepath` to automatically add it, or manually modify your PATH in
your shell's config file (i.e. ~/.bashrc).
done! ✨ 🌟 ✨
On Debian Linux, this message can be ignored. Instead, simply log out and log back in again. The per-user .local/bin directory is supported by default, but is only added to the path when exists at the moment you logged in. (it may also suffice to simply re-open your terminal window, so try that first if you would prefer to avoid logging out)
Installing Python versions via uv
Just run uv python install 3.13
At the moment, uv does not have the stable release of Python 3.13, so it installs a release candidate version instead:
$ uv python install 3.13 Searching for Python versions matching: Python 3.13 Installed Python 3.13.0rc3 in 1.49s + cpython-3.13.0rc3-linux-x86_64-gnu
Running Python by version with uv
"uv run" can accept a Python version. If the command is "python", the interactive Python prompt is started. If it's a Python script with the .py extension, the script is run.
$ uv run --python 3.13 python Python 3.13.0rc3 (main, Oct 2 2024, 17:18:08) [Clang 18.1.8 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
One of the headline features, the new multiline editor, seems to work like a treat. Here, I've used the cursor up key to edit the if line after I hit enter and started typing the if-statement's body:
Creating a virtual environment with specific Python version with uv
The "uv venv" command creates a virtual environment. Again, a Python version can be specified. When the environment is activated (which lasts until you close that shell or terminal window), the python command refers to the specified version instead of the default version.
$ uv venv --python 3.13 venv-3.13 Using CPython 3.13.0rc3 Creating virtual environment at: venv-3.13 Activate with: source venv-3.13/bin/activate kepler@bert:~$ source venv-3.13/bin/activate (venv-3.13) $ python Python 3.13.0rc3 (main, Oct 2 2024, 17:18:08) [Clang 18.1.8 ] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
This page (Installing Python 3.13 using uv) was last updated on October 08, 2024.
Text editor powered by tinymce.