Debian basic config

toggle python 3 by default instead of python 2.7

debian is still delivered with 2.7 as the default version of python. /usr/bin/python is in fact a symlink to the current default versions binary.

The update-alternatives scripts allows to change this.

1
2
root@debdev ~# ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 Nov 24  2017 /usr/bin/python -> python2.7

Check with versions are already installed

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@debdev ~# dpkg -l | grep python
...
ii  python2.7        
...
ii  python3          
...
ii  python3.5        
...
root@debdev ~# ls -l /usr/bin/python*
/usr/bin/python -> python2.7
/usr/bin/python2 -> python2.7
/usr/bin/python2.7
/usr/bin/python3 -> python3.5
/usr/bin/python3.5

In my example Python 2.7 and 3.5 are installed. python3 is a symlink to 3.5

To set python 3.5 as default use the update-alternatives scripts. You can set more alternatives the last number defines the priority. Higher number means higher priority.

1
2
root@debdev ~# update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
root@debdev ~# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

After setting more then one alternatives you can easily switch the version by

1
root@debdev ~# update-alternatives --config python

 

 

 

This information was taken from this website :
https://michlstechblog.info/blog/debian-set-python-3-as-default/#:~:text=debian%20is%20still%20delivered%20with,scripts%20allows%20to%20change%20this.&text=To%20set%20python%203.5%20as%20default%20use%20the%20update%2Dalternatives%20scripts.

 

Leave a Comment