Categories
Tags
167 words
1 minutes
Set default version for python
Set default version for python in debina/ubuntu machines.
- Check Installed Python Version
- Install the Desired Python Version (if not already installed)
- Create a symbolic link to point the
python
command topython3
. - Verify that the
python
command points to the correct Python version
python3 --version
sudo apt update && sudo apt install python3.12
sudo ln -s /usr/bin/python3 /usr/bin/python
python --version
Update Alternatives (Optional)
- Add the Python versions to the alternatives system
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.12 2
2.Configure the default Python version
sudo update-alternatives --config python
- Verify the Alternatives Configuration
python --version
NOTEBy following these steps, you can ensure that the python command on your Ubuntu system points to your desired Python 3 version. This can help standardize scripts and commands that rely on the python command, ensuring they use the correct Python interpreter.
Conclusion
That’s it! You’ve learnt, how to setup the default version for python in linux machines. If you have any doubts/issues/errors with the above contents, feel free to contact me
. Cheers, Happy learning.