Install Typer¶
The first step is to set up your project and add Typer.
Install uv, then create a project and add Typer:
$ uv init awesome-project --bare
$ cd awesome-project
$ uv add typer
---> 100%
uv add creates the project's virtual environment in .venv, adds Typer to pyproject.toml, and creates uv.lock so the same package versions can be installed later.
What these commands do
uv init: create a new Python project.awesome-project: create the project in a new directory with this name.--bare: create only the minimalpyproject.tomlfile, without generating a samplemain.py,README.md, or other files. You will create the application files yourself in the next steps of this tutorial.
Then cd awesome-project enters the new project directory before adding Typer.
uv will use a compatible Python version already installed on your system, or download one if needed.
When you run uv add, it selects compatible versions of Typer and all the packages Typer depends on. It records the exact versions in uv.lock, making it possible to install the same package versions later on another computer or when distributing the application.
Creating or updating this file is called locking the project dependencies. uv does this automatically when you add a package.
By default, typer comes with rich and shellingham.
Activate the Virtual Environment¶
uv add typer installs both the Typer library and the typer command in the project's .venv.
You can normally run project commands with uv run. But to configure and use shell completion for the first-class typer command, activate the project's virtual environment so that typer is available directly in your shell.
$ source .venv/bin/activate
$ .venv\Scripts\Activate.ps1
$ source .venv/Scripts/activate
Enable completion for your current shell with:
$ typer --install-completion
Restart your terminal for the new completion configuration to take effect.
Activate the project's virtual environment again in each new terminal session where you want to use the typer command directly.
Using pip instead
If you prefer to manage a virtual environment and packages manually, create and activate a virtual environment and then install Typer with pip install typer.
Read the Virtual Environments guide for the detailed steps.