How To Install python-chardet on Debian 9

In this tutorial we learn how to install python-chardet on Debian 9. python-chardet is universal character encoding detector for Python2

Introduction

In this tutorial we learn how to install python-chardet on Debian 9.

What is python-chardet

python-chardet is:

Chardet takes a sequence of bytes in an unknown character encoding, and attempts to determine the encoding.

Supported encodings:

  • ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants)
  • Big5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (Traditional and Simplified Chinese)
  • EUC-JP, SHIFT_JIS, ISO-2022-JP (Japanese)
  • EUC-KR, ISO-2022-KR (Korean)
  • KOI8-R, MacCyrillic, IBM855, IBM866, ISO-8859-5, windows-1251 (Cyrillic)
  • ISO-8859-2, windows-1250 (Hungarian)
  • ISO-8859-5, windows-1251 (Bulgarian)
  • windows-1252 (English)
  • ISO-8859-7, windows-1253 (Greek)
  • ISO-8859-8, windows-1255 (Visual and Logical Hebrew)
  • TIS-620 (Thai)

This library is a port of the auto-detection code in Mozilla.

There are three methods to install python-chardet on Debian 9. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install python-chardet Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install python-chardet using apt-get by running the following command:

sudo apt-get -y install python-chardet

Install python-chardet Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install python-chardet using apt by running the following command:

sudo apt -y install python-chardet

Install python-chardet Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install python-chardet using aptitude by running the following command:

sudo aptitude -y install python-chardet

How To Uninstall python-chardet on Debian 9

To uninstall only the python-chardet package we can use the following command:

sudo apt-get remove python-chardet

Uninstall python-chardet And Its Dependencies

To uninstall python-chardet and its dependencies that are no longer needed by Debian 9, we can use the command below:

sudo apt-get -y autoremove python-chardet

Remove python-chardet Configurations and Data

To remove python-chardet configuration and data from Debian 9 we can use the following command:

sudo apt-get -y purge python-chardet

Remove python-chardet configuration, data, and all of its dependencies

We can use the following command to remove python-chardet configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-chardet

Dependencies

python-chardet have the following dependencies:

References

Summary

In this tutorial we learn how to install python-chardet package on Debian 9 using different package management tools: apt, apt-get and aptitude.