Skip to content

How to Run a Python REPL with uv

uv does not currently officially support a system-level installation of Python, however, you can try it in preview mode.

To start an interactive Python REPL (Read-Eval-Print Loop) session using uv:

$ uv run python

This command will:

  1. Create or use an existing virtual environment if in a project (i.e. the project has a pyproject.toml file)
  2. Install any required dependencies
  3. Launch an interactive Python session

Using a Specific Python Version

To run the REPL with a particular Python version:

$ uv run --python 3.12 python

If the requested Python version is not installed, uv will download and install it automatically.

Running the REPL with Additional Dependencies

To run Python with specific packages available:

$ uv run --with pandas --with numpy python

This will create an isolated environment with the requested packages installed before launching the REPL.

Running the REPL Isolated from a Project

When working in a project directory but wanting to run a clean REPL without project dependencies:

$ uv run --no-project --isolated python

--no-project on its own skips reading pyproject.toml, but uv still finds the .venv in the directory and its packages stay importable. --isolated is what forces the ephemeral environment.

If you need regular access to a Python REPL, install IPython as a tool with uv tool install ipython. uv python install also writes versioned shims such as python3.12 into ~/.local/bin, covered in How to Add Python to Your System PATH with uv.

Learn more

Last updated on