I'm using Ubuntu 20.04 and default Python3 version is 3.8.2 but I want to use the Python 3.7.6 .
I don't care if the Python 3.8.2 will be uninstalled or not. I only want to make sure every time I use python3
command it runs the Python 3.7.6 (instead of 3.8.2).
What should I do?

- 63
-
4Hey mhn2! It's generally not advised to mess up with the default Python in Ubuntu. For what reason do you want to Python 3.7.6 instead of the default one? Are you into programming? – Random Person Sep 05 '20 at 13:19
-
@technastic_tc I have done all of my projects with python 3.7.6 in windows and now I have moved to Ubuntu. I don't want to face any kind of problem when running my projects I did before today. – mhn2 Sep 05 '20 at 13:24
-
1@mhn2 the packages that come with Ubuntu may have issues if they're using a 3.8 feature and you've made them all run with 3.7. – OrangeDog Sep 05 '20 at 22:55
-
1Related: How do I install a different Python version using apt-get?, How to make 'python' program command execute Python 3? or more specifically, How to change python3 from python3.5 to python3.6 – wjandrea Sep 05 '20 at 23:38
1 Answers
Don't mess with, remove or replace the preinstalled Python interpreters!
The easiest option for Ubuntu LTS releases is to add the deadsnakes PPA which provides the latest of each minor Python version (3.6.x, 3.7.x, 3.8.x, ...) as regular packages, so it integrates well with your system. Once installed, you can call those versions with the python3.6
etc. command instead of plain python3
.
Alternatively, you can use e.g. pyenv to manage multiple independent interpreter versions for your development projects. Find it here, or use the simple installer. This gives you more flexibility and control, but is also a bit more effort and complex IMO.
Yet another possibility would be to use a containerization technology such as Docker to have always the same, reproducible and isolated build and run environments for your development.
Besides though, most not too special Python 3 code is compatible with newer interpreters, unless you use specifically deprecated methods and features. It's always good to keep testing your projects against newer releases and adapt/fix them as needed to keep them alive.

- 107,489