Last modified: Mar 27, 2025 By Alexander Williams

How to Install Humanize in Python

The Humanize library in Python helps format data in a human-readable way. It converts numbers, dates, and sizes into easy-to-understand text.

This guide will walk you through installing and using Humanize in Python. Follow the steps below to get started.

Prerequisites

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

 
python --version


Python 3.8.5

If you get a ModuleNotFoundError, refer to this guide on solving Python module errors.

Install Humanize Using pip

The easiest way to install Humanize is using pip. Open your terminal or command prompt and run:

 
pip install humanize


Successfully installed humanize-4.4.0

This will download and install the latest version of Humanize.

Verify Installation

To ensure Humanize is installed correctly, run:

 
python -c "import humanize; print(humanize.__version__)"


4.4.0

If you see the version number, the installation was successful.

Basic Usage of Humanize

Humanize offers many functions. Here are some common examples.

Format Numbers

Use humanize.intcomma to add commas to large numbers:

 
import humanize
print(humanize.intcomma(1234567))


1,234,567

Format Dates

Use humanize.naturalday to format dates:

 
from datetime import datetime
print(humanize.naturalday(datetime.now()))


today

Format File Sizes

Use humanize.naturalsize to format file sizes:

 
print(humanize.naturalsize(1024))


1.0 KB

Common Errors and Fixes

If you encounter errors, check the following:

1. Ensure pip is up to date. Run pip install --upgrade pip.

2. Verify Python is installed correctly. Check with python --version.

3. If you face a ModuleNotFoundError, follow this troubleshooting guide.

Conclusion

Humanize is a powerful library for formatting data. It makes numbers, dates, and sizes easy to read.

By following this guide, you can install and use Humanize in Python. Try it out in your next project!