How To Install python-cjson on Ubuntu 18.04

In this tutorial we learn how to install python-cjson on Ubuntu 18.04. python-cjson is Very fast JSON encoder/decoder for Python

Introduction

In this tutorial we learn how to install python-cjson on Ubuntu 18.04.

What is python-cjson

python-cjson is:

JSON stands for JavaScript Object Notation and is a text based lightweight data exchange format which is easy for humans to read/write and for machines to parse/generate. JSON is completely language independent and has multiple implementations in most of the programming languages, making it ideal for data exchange and storage.

The module is written in C and it is up to 250 times faster when compared to the other Python JSON implementations which are written directly in Python. This speed gain varies with the complexity of the data and the operation and is the range of 10-200 times for encoding operations and in the range of 100-250 times for decoding operations.

There are three methods to install python-cjson on Ubuntu 18.04. 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-cjson 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-cjson using apt-get by running the following command:

sudo apt-get -y install python-cjson

Install python-cjson Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install python-cjson

Install python-cjson 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 Ubuntu. Update apt database with aptitude using the following command.

sudo aptitude update

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

sudo aptitude -y install python-cjson

How To Uninstall python-cjson on Ubuntu 18.04

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

sudo apt-get remove python-cjson

Uninstall python-cjson And Its Dependencies

To uninstall python-cjson and its dependencies that are no longer needed by Ubuntu 18.04, we can use the command below:

sudo apt-get -y autoremove python-cjson

Remove python-cjson Configurations and Data

To remove python-cjson configuration and data from Ubuntu 18.04 we can use the following command:

sudo apt-get -y purge python-cjson

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

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

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

References

Summary

In this tutorial we learn how to install python-cjson package on Ubuntu 18.04 using different package management tools: apt, apt-get and aptitude.