This guide will discuss how to install Python manually on a Linux machine. For your convenience, we will also discuss how to uninstall Python installed in this way.
Steps to Follow to Install Python Manually
First of all, we need to update package repositories and install dependencies.
Step 1: Update repositories
On Debian-based distributions, execute (modify the commands according to the distro you are running):
|
|
Step 2: Download the stable release of Python on its official website
In this step, go to https://www.python.org/downloads/source/ and download XZ compressed source tarball (.tar.xz) file. This file contains all the source files we can build to get the Python we want (I am downloading Python 3.10.5, so I get, Python-3.10.5.tar.xz file).
Step 3: Extract the tarball
Use the inbuilt extraction functionality to extract the tarball, or you can use the tar command in Python as follows
|
|
(In my case, I have to run tar -xf Python-3.10.5.tar.xz
)
Step 3: Run the configuration This is accomplished by running the following command on Linux Terminal
|
|
That is, cd
into the extracted directory and run configure file.
Step 4: Build the package
Since we want to install this Python version along with the preinstalled one, we will run:
|
|
Now, Python 3.10 is installed, and we can wake it up by running
|
|
or
|
|
Remove Python install Manually
To do that, save the following commands on the bash file named “uninstall_python.sh” (you can give it any name, really) and execute it with sudo privileges.
|
|
Execute the bash script by running:
|
|
In my case, I will cd into the location of uninstall_python.sh and run the command.
|
|