Last modified: Mar 27, 2025 By Alexander Williams

How to Install Typer in Python Step by Step

Typer is a Python library for building command-line interfaces (CLI). It is simple and intuitive. This guide will help you install Typer step by step.

Prerequisites

Before installing Typer, ensure you have Python installed. You can check this by running:


python --version


Python 3.8.5

If you see an error, install Python first. Typer requires Python 3.6 or higher.

Install Typer Using pip

The easiest way to install Typer is using pip, Python's package manager. Open your terminal and run:


pip install typer


Successfully installed typer-0.4.1

This command installs the latest version of Typer. If you face issues like ModuleNotFoundError, check our guide on how to solve ModuleNotFoundError.

Verify the Installation

After installation, verify Typer is installed correctly. Run the following command:


pip show typer


Name: typer
Version: 0.4.1
Summary: Typer is a library for building CLI applications.

If you see the Typer details, the installation was successful.

Create a Simple Typer App

Now, let's create a simple CLI app to test Typer. Create a file named app.py and add the following code:


import typer

app = typer.Typer()

@app.command()
def greet(name: str):
    typer.echo(f"Hello, {name}!")

if __name__ == "__main__":
    app()

This code defines a CLI command greet that takes a name and prints a greeting.

Run the Typer App

To run the app, use the following command in your terminal:


python app.py greet John


Hello, John!

If you see the greeting, your Typer app is working correctly.

Install Optional Dependencies

Typer has optional dependencies for extra features. Install them using:


pip install typer[all]

This includes color support and other enhancements.

Conclusion

Installing Typer in Python is simple with pip. Follow the steps above to set it up and create CLI apps easily. For more help, check the official Typer documentation.