How To Install python3-astor on Ubuntu
Posted on April 1, 2023  (Last modified on May 20, 2023 )
3 minutes • 518 words
Introduction
In this tutorial we learn how to install python3-astor on Ubuntu.
What is python3-astor
python3-astor is:
astor is designed to allow easy manipulation of Python source via the AST.
There are some other similar libraries, but astor focuses on the following areas:
Round-trip back to Python via Armin Ronacher’s codegen.py module:
- Modified AST doesn’t need linenumbers, ctx, etc. or otherwise be directly compileable
Dump pretty-printing of AST
- Harder to read than round-tripped code, but more accurate to figure out what is going on.
- Easier to read than dump from built-in AST module
Non-recursive treewalk
- Sometimes you want a recursive treewalk (and astor supports that, starting at any node on the tree), but sometimes you don’t need to do that. astor doesn’t require you to explicitly visit sub-nodes unless you want to:
- You can add code that executes before a node’s children are visited, and/or
- You can add code that executes after a node’s children are visited, and/or
- You can add code that executes and keeps the node’s children from being visited (and optionally visit them yourself via a recursive call)
- Write functions to access the tree based on object names and/or attribute names
- Enjoy easy access to parent node(s) for tree rewriting
This package provides Python 3 module bindings only.
There are three methods to install python3-astor on Ubuntu. 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-astor 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-astor using apt-get by running the following command:
sudo apt-get -y install python3-astor
Install python3-astor Using apt
Update apt database with apt using the following command.
sudo apt update
After updating apt database, We can install python3-astor using apt by running the following command:
sudo apt -y install python3-astor
Install python3-astor 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 python3-astor using aptitude by running the following command:
sudo aptitude -y install python3-astor
How To Uninstall python3-astor on Ubuntu
To uninstall only the python3-astor package we can use the following command:
sudo apt-get remove python3-astor
Uninstall python3-astor And Its Dependencies
To uninstall python3-astor and its dependencies that are no longer needed by Ubuntu, we can use the command below:
sudo apt-get -y autoremove python3-astor
Remove python3-astor Configurations and Data
To remove python3-astor configuration and data from Ubuntu we can use the following command:
sudo apt-get -y purge python3-astor
Remove python3-astor configuration, data, and all of its dependencies
We can use the following command to remove python3-astor configurations, data and all of its dependencies, we can use the following command:
sudo apt-get -y autoremove --purge python3-astor
Dependencies
python3-astor have the following dependencies:
References
Summary
In this tutorial we learn how to install python3-astor package on Ubuntu using different package management tools: apt, apt-get and aptitude.