To revert to an older Python version and set it as the default, you can use
update-alternatives on Debian-based systems or manipulate symbolic links. Here's how:
update-alternatives (Debian-based like Ubuntu)
If you've set up multiple Python versions using
update-alternatives, you can switch between them by running:
sudo update-alternatives --config python3
You'll get a menu to choose the Python version. Select the one you want.
Using Symbolic Links (Generic)
If you've manually changed the symbolic link for Python, you can revert it like this:
Remove the existing link:
sudo rm /usr/bin/python3
Create a new link pointing to the original Python executable:
sudo ln -s /usr/bin/python3.x /usr/bin/python3
python3.x with the original version you want, like
Bash Script Example
If you want to automate it, you could write a Bash script:
# Using update-alternatives sudo update-alternatives --config python3 # OR using symbolic links # sudo rm /usr/bin/python3 # sudo ln -s /usr/bin/python3.x /usr/bin/python3 echo "Python version switched."
Remember to give execute permissions to the script:
chmod +x switch_python_version.sh
Then run it:
That should set your Python version back to the original one.