Python Troubleshooting and Installation Summary
This document summarizes the issues encountered and troubleshooting steps taken based on the provided command history. It also provides guidance on proper Python installation.
Issues Encountered
- Terminal Failure After Changing Python Version:
- After installing Python 3.14 and setting it as the default using
update-alternatives, bothgnome-terminalandterminatorfailed to launch. - Errors were related to missing or incompatible Python libraries (
psutilandgi). gnome-terminalalso had a typo in it's shebang.
- After installing Python 3.14 and setting it as the default using
- Incompatible Python Libraries:
- The alpha version of Python 3.14 caused incompatibility issues with
psutilandgilibraries, which are essential for the terminal applications.
- The alpha version of Python 3.14 caused incompatibility issues with
Troubleshooting Steps
- Corrected
gnome-terminalShebang:- Used
sudo vim /usr/bin/gnome-terminalto correct the shebang from/usri/bin/python3to/usr/bin/python3.
- Used
- Switched Python Versions:
- Used
sudo update-alternatives --config python3to switch back to a stable Python version (Python 3.10).
- Used
- Reinstalled Python Libraries:
sudo apt-get install --reinstall python3-psutil gir1.2-glib-2.0 python3-giwas used to reinstall the python modules that the terminal applications use.
- Rebooted the system:
- Reboots where used in an attempt to solve the issue.
Proper Python Installation and Version Management
Adding the DeadSnakes PPA (for newer Python versions):
sudo add-apt-repository ppa:deadsnakes/ppaadds the DeadSnakes PPA, which provides newer Python versions.sudo apt updateupdates the package list.
Installing a Specific Python Version:
sudo apt-get install python3.11(orpython3.14) installs the desired Python version.
Managing Python Versions with
update-alternatives(Use with Caution):sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2registers a Python version withupdate-alternatives.sudo update-alternatives --config python3allows you to select the default Python version.- Recommendation: Avoid changing the system's default Python version unless absolutely necessary.
Using Virtual Environments (Recommended):
- For project-specific Python versions and dependencies, use virtual environments:
python3.14 -m venv my_envcreates a virtual environment.source my_env/bin/activateactivates the environment.deactivatedeactivates the environment.
- Virtual environments isolate project dependencies and prevent system-wide conflicts.
- This is the recommended way to use python 3.14.
- For project-specific Python versions and dependencies, use virtual environments:
Key Recommendations
- Use virtual environments for project-specific Python versions.
- Avoid changing the system's default Python version unless you fully understand the consequences.
- Stick to stable Python versions for system-wide use.
- When using
update-alternativesensure that the path to the python executable is correct. - If terminal problems occur after python changes, switch back to a stable python version, and reinstall any broken python modules.
Written by A.M. Rinas