How I can install unidecode python module on Linux?

Unidecode is a Python module that converts Unicode text into plain ASCII characters. This is useful when working with text containing special characters or non-English characters that need to be simplified for processing or display.

What is Unidecode?

Unidecode translates Unicode characters to their closest ASCII equivalents. For example:

  • "ko?u??ek" becomes "kozuscek"
  • "??" becomes "Bei Jing"
  • "naïve" becomes "naive"
  • "Café résumé" becomes "Cafe resume"

This module is commonly used for processing international data, user-generated content, and creating URL-friendly strings.

Prerequisites

Before installing Unidecode, ensure you have Python and pip installed. Python 2.7.9+ or Python 3.4+ come with pip pre-installed. Check if Unidecode is already available ?

pip show unidecode

Installing Unidecode on Linux

Method 1: Using pip3

The simplest way to install Unidecode is using pip3 ?

pip3 install unidecode

Method 2: Installing pip first (if not available)

If you get a 'pip: command not found' error, install pip first ?

sudo apt install python3-pip
pip3 install unidecode

Method 3: Using Virtual Environment (Recommended)

Using a virtual environment isolates your project dependencies and prevents conflicts ?

# Create a new virtual environment
python3 -m venv myenv

# Activate the environment
source myenv/bin/activate

# Install Unidecode
pip install unidecode

Testing the Installation

Once installed, test Unidecode with this simple example ?

from unidecode import unidecode

# Test with special characters
special_string = "Café résumé naïve"
ascii_string = unidecode(special_string)
print(f"Original: {special_string}")
print(f"ASCII: {ascii_string}")
Original: Café résumé naïve
ASCII: Cafe resume naive

Practical Example

Here's a more comprehensive example showing Unidecode with different languages ?

from unidecode import unidecode

texts = [
    "??",           # Chinese
    "??????",         # Russian  
    "François",       # French
    "São Paulo",      # Portuguese
    "Ñoño"           # Spanish
]

for text in texts:
    print(f"{text} ? {unidecode(text)}")
?? ? Bei Jing
?????? ? moskva
François ? Francois
São Paulo ? Sao Paulo
Ñoño ? Nono

Uninstalling Unidecode

If you need to remove Unidecode, use this command ?

pip3 uninstall unidecode

Conclusion

Installing Unidecode on Linux is straightforward using pip3. Use virtual environments for project isolation, and test your installation with simple Unicode-to-ASCII conversions to ensure it works correctly.

Updated on: 2026-03-24T17:08:59+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements