How to Use the Installer Script
-
Make the script executable: Make the script executable using the
chmodcommand:chmod +x install_latest_python.sh -
Run the script: Execute the script:
./install_latest_python.sh
This will automatically install the latest Python version (as per the specified PYTHON_VERSION in the script) and pip. Modify PYTHON_VERSION=3.12 to the specific version you want, such as 3.12.7 if necessary.
How the Uninstaller Works:
-
Detecting Python version: The script detects the installed Python version using
python3 --versionand extracts the version number. If no Python version is detected, the script exits with an error message. -
Uninstalling Python: The script uninstalls the detected Python version along with related packages (
venv,dev,distutils). -
Uninstalling pip: The script removes
pip. -
Removing the
deadsnakesPPA: It checks if thedeadsnakesPPA exists in the system and removes it. -
Cleaning up remaining packages: It runs
apt autoremoveto remove unnecessary dependencies. -
Verifying uninstallation: It checks whether Python and
pipare successfully uninstalled.
How to Use the Uninstaller Script
-
Create the script file: Save the script as
uninstall_python.sh.nano uninstall_python.sh -
Make the script executable: Make the script executable using the
chmodcommand:chmod +x uninstall_python.sh -
Run the script: Execute the script:
./uninstall_python.sh