In order to change to default python version on your Raspbian GNU/Linux first list all available python versions:
# ls /usr/bin/python* /usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.2 /usr/bin/python3.2mu /usr/bin/python3mu
Your output may be different. If the version you are looking for is not available then use apt-get
command to install it. eg. apt-get install python3
Next setup alternatives:
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode # update-alternatives --install /usr/bin/python python /usr/bin/python3.2 2 update-alternatives: using /usr/bin/python3.2 to provide /usr/bin/python (python) in auto mode
Since we have setup python3.2
with a higher priority it should be now your default:
# python --version Python 3.2.3
To swap between python version use update-alternatives
command:
# update-alternatives --config python There are 2 choices for the alternative python (providing /usr/bin/python). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/python3.2 2 auto mode 1 /usr/bin/python2.7 1 manual mode 2 /usr/bin/python3.2 2 manual mode Press enter to keep the current choice[*], or type selection number: 1 update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode
Your python version should now be changed to reflect the above selection:
# python --version Python 2.7.3