Last modified: Apr 03, 2025 By Alexander Williams

Install PyICU in Python Step by Step

PyICU is a Python extension for the ICU library. It helps handle Unicode, localization, and text processing. This guide will walk you through installing PyICU.

Prerequisites

Before installing PyICU, ensure you have Python and pip installed. You also need the ICU library on your system.

Check your Python version using python --version. For pip, run pip --version.


python --version
pip --version

Step 1: Install ICU Library

PyICU requires the ICU library. Install it based on your operating system.

For Ubuntu/Debian


sudo apt-get install libicu-dev

For macOS


brew install icu4c

For Windows

Download ICU binaries from the ICU website. Add them to your system PATH.

Step 2: Install PyICU via pip

Use pip to install PyICU. Run the following command:


pip install PyICU

If you encounter a ModuleNotFoundError, check our guide on solving ModuleNotFoundError.

Step 3: Verify Installation

After installation, verify PyICU works. Open Python and import the module.


import icu
print(icu.ICU_VERSION)


'72.1'

If no errors appear, PyICU is installed correctly.

Common Installation Issues

Some users face issues during installation. Here are common fixes.

Error: ICU Not Found

Ensure the ICU library is installed. On Linux, use apt-get or yum. On macOS, use brew.

Permission Denied

Use sudo for Linux/macOS or run Command Prompt as admin on Windows.


sudo pip install PyICU

Compiler Errors

Install build tools. On Ubuntu, run:


sudo apt-get install build-essential python3-dev

Using PyICU

Here’s a simple example of PyICU for Unicode normalization.


from icu import Normalizer2, UNORM_NFC
normalizer = Normalizer2.getInstance(None, "nfc", UNORM_NFC)
text = "Café"
normalized_text = normalizer.normalize(text)
print(normalized_text)


'Café'

Conclusion

Installing PyICU is straightforward if dependencies are met. Follow the steps above to avoid common errors. PyICU is powerful for Unicode and text processing.

For more Python guides, explore our tutorials. If you face issues, check our guide on ModuleNotFoundError.