如何變更python預設版本

一般來說,電腦裡會有許多版本的python,由下述方式可以知道有那些版本

pi@raspb2:~/Downloads $ sudo ls /usr/bin/python*

sudo: unable to resolve host raspb2

/usr/bin/python /usr/bin/python2.7-config /usr/bin/python3.5 /usr/bin/python3.5m-config /usr/bin/python3m-config

/usr/bin/python2 /usr/bin/python2-config /usr/bin/python3.5-config /usr/bin/python3-config /usr/bin/python-config

/usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.5m /usr/bin/python3m

而目前的版本為何呢?

pi@raspb2:~/Downloads $ python --version

Python 2.7.13

利用alias來變更預設版本,並且重新login .bashrc,即可變更預設的版本。

pi@raspb2:~/Downloads $ alias python="/usr/bin/python3.5"

pi@raspb2:~/Downloads $ . ~/.bashrc

pi@raspb2:~/Downloads $ python --version

Python 3.5.3