How To Install python3-cattr on Debian 12

Learn how to install python3-cattr on Debian 12 with this tutorial. python3-cattr is composable complex class support for attrs and dataclasses

Introduction

In this tutorial we learn how to install python3-cattr on Debian 12.

What is python3-cattr

python3-cattr is:

cattrs is an open source Python library for structuring and unstructuring data. cattrs works best with attrs classes, dataclasses and the usual Python collections, but other kinds of classes are supported by manually registering converters.

Python has a rich set of powerful, easy to use, built-in data types like dictionaries, lists and tuples. These data types are also the lingua franca of most data serialization libraries, for formats like json, msgpack, yaml or toml.

Data types like this, and mappings like dict s in particular, represent unstructured data. Your data is, in all likelihood, structured: not all combinations of field names or values are valid inputs to your programs. In Python, structured data is better represented with classes and enumerations. attrs is an excellent library for declaratively describing the structure of your data, and validating it.

When you’re handed unstructured data (by your network, file system, database…), uattrs helps to convert this data into structured data. When you have to convert your structured data into data types other libraries can handle, cattrs turns your classes and enumerations into dictionaries, integers and strings.

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

Install python3-cattr Using apt-get

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

sudo apt-get update

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

sudo apt-get -y install python3-cattr

Install python3-cattr Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install python3-cattr

Install python3-cattr 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 python3-cattr using aptitude by running the following command:

sudo aptitude -y install python3-cattr

How To Uninstall python3-cattr on Debian 12

To uninstall only the python3-cattr package we can use the following command:

sudo apt-get remove python3-cattr

Uninstall python3-cattr And Its Dependencies

To uninstall python3-cattr and its dependencies that are no longer needed by Debian 12, we can use the command below:

sudo apt-get -y autoremove python3-cattr

Remove python3-cattr Configurations and Data

To remove python3-cattr configuration and data from Debian 12 we can use the following command:

sudo apt-get -y purge python3-cattr

Remove python3-cattr configuration, data, and all of its dependencies

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

sudo apt-get -y autoremove --purge python3-cattr

Dependencies

python3-cattr have the following dependencies:

References

Summary

In this tutorial we learn how to install python3-cattr package on Debian 12 using different package management tools: apt, apt-get and aptitude.