How to make Ubuntu 18.04 LTS use python 3.7 as default?

Bo Berglund bo.berglund at gmail.com
Thu Jul 30 09:54:45 UTC 2020


On Thu, 30 Jul 2020 06:46:23 +0000, Sorin Srbu <sorin.srbu at ki.se>
wrote:

>On Thu, 2020-07-30 at 08:15 +0200, Bo Berglund wrote:
>> It has python 2.7 installed as its default python and now I am getting
>> problems because apparently 2.7 is no longer the version used for some
>> of my tools, which prints messages that all upgrades must use python 3
>> (actually 3.5 or higher).
>> I have managed to install 3.7 even though the ubuntu apt system only
>> provides a much lower version.
>> I did that using this instruction page:
>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flinuxize.com%2Fpost%2Fhow-to-install-python-3-7-on-ubuntu-18-04%2F&data=02%7C01%7Csorin.srbu%40ki.se%7C35f91e03ea154f932f1308d834502ad6%7Cbff7eef1cf4b4f32be3da1dda043c05d%7C0%7C0%7C637316866215256407&sdata=MdIq4p8lPq5PwF6LTWoWommxHH7y%2F7nE4GvT%2BxhuTLA%3D&reserved=0
>> 
>> So now I have this:
>> ~$ python --version
>> Python 2.7.17
>> ~$ python2 --version
>> Python 2.7.17
>> ~$ python3 --version
>> Python 3.6.9
>> ~$ python3.7 --version
>> Python 3.7.8
>> 
>> As you can see I seem to have 3 installed versions but the default
>> version is the oldest...
>> 
>> So how can I make python use version 3 (or even 3.7.8)?
>> 
>
>Hello Bo!
>
>Maybe try "sudo update-alternatives --config python"?
>
>See eg 
>https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux#h2-change-python-version-system-wide
> for a nice howto and guide.
>

Thanks for the input! Much appreciated.

I have done this for all of my installed pythons so now the available
pythons are:

update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.5
/usr/bin/python3.6
/usr/bin/python3.7

But when I look in /usr/bin I see a problem (edited list to remove
leading fluff):

ls -la /usr/bin/python*
/usr/bin/python -> /etc/alternatives/python
/usr/bin/python2 -> python2.7
/usr/bin/python2.7
/usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
/usr/bin/python2-config -> python2.7-config
/usr/bin/python3 -> python3.6
/usr/bin/python3.5
/usr/bin/python3.5m
/usr/bin/python3.6
/usr/bin/python3.6m
/usr/bin/python3.7
/usr/bin/python3.7m
/usr/bin/python3-futurize
/usr/bin/python3m -> python3.6m
/usr/bin/python3-pasteurize
/usr/bin/python3-pbr
/usr/bin/python3-wsdump
/usr/bin/python-config -> python2.7-config

Note the last line concerning the config!!!!
It still points to python2.7

Is this really correct or is the config either portable or not used?


-- 
Bo Berglund
Developer in Sweden





More information about the ubuntu-users mailing list