How To Install python-asteval on Debian 10

Learn how to install python-asteval on Debian 10 with this tutorial. python-asteval is minimalistic evaluator of Python 2 expression using ast module

Introduction

In this tutorial we learn how to install python-asteval on Debian 10.

What is python-asteval

python-asteval is:

ASTEVAL is a safe(ish) evaluator of Python expressions and statements, using Python’s ast module. The idea is to provide a simple, safe, and robust miniature mathematical language that can handle user-input. The emphasis here is on mathematical expressions, and so many functions from numpy are imported and used if available.

Many Python lanquage constructs are supported by default, These include slicing, subscripting, list comprehension, conditionals (if-elif-else blocks and if expressions), flow control (for loops, while loops, and try-except-finally blocks). All data are Python objects, and built-in data structures (dictionaries, tuple, lists, numpy arrays, strings) are fully supported by default.

Many of the standard builtin Python functions are available, as are all mathemetical functions from the math module. If the numpy module is installed, many of its functions will also be available. Users can define and run their own functions within the confines of the limitations of asteval.

There are several absences and differences with Python, and asteval is by no means an attempt to reproduce Python with its own ast module. Some of the most important differences and absences are:

  • Variable and function symbol names are held in a simple symbol table (a single dictionary), giving a flat namespace.
  • creating classes is not supported.
  • importing modules is not supported.
  • function decorators, yield, lambda, exec, and eval are not supported.
  • files can only be opened in read-only mode.

In addition, accessing many internal methods and classes of objects is forbidden in order to strengthen asteval against malicious user code. .

This package installs the library for Python 2.

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

sudo apt-get -y install python-asteval

Install python-asteval Using apt

Update apt database with apt using the following command.

sudo apt update

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

sudo apt -y install python-asteval

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

sudo aptitude -y install python-asteval

How To Uninstall python-asteval on Debian 10

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

sudo apt-get remove python-asteval

Uninstall python-asteval And Its Dependencies

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

sudo apt-get -y autoremove python-asteval

Remove python-asteval Configurations and Data

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

sudo apt-get -y purge python-asteval

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

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

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

Dependencies

python-asteval have the following dependencies:

References

Summary

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