Skip to content

Installation

Ansy is available on PyPI and can be installed with pip.

pip install ansy

This installs the latest version from PyPI. If you've got Python 3.8+ and pip installed, you're good to go. See also

Or you can also install Ansy from source:

git clone https://github.com/anas-shakeel/ansy.git
cd ansy
pip install .

Quick Check

To verify the installation, run ansy alone or with -h flag in the terminal:

ansy -h

You should see help text from ansy!

Example Usage

Here’s a minimal example that prints colored text onto the terminal:

from ansy import printc

printc("The background is red!", bgcolor="red")

Windows Console Support

Ansy has zero dependencies, but if you're on Windows, you may need to install colorama to enable proper color rendering in the Command Prompt or PowerShell.

Install colorama (only on Windows)

pip install colorama

Then initialize it in your script before using ansy:

from ansy import printc
from colorama import just_fix_windows_console

just_fix_windows_console()
printc("The background is red!", bgcolor="red")

This ensures that ANSI escape codes display correctly on Windows terminals.

Note

This step is only needed on Windows. On Linux and MacOS, ansy works out of the box.