I had installed Python 3.7 which according to tutorial in this blog(i change the Python version to 3.7.2):


However, when I checked my default python with

python --version

it still showing me 2.7.13 version

I had tried to set the default version with the following command:

alias python='/usr/bin/python3.7'
$ . ~/.bashrc

but then when i check my Python version it showing error which cannot found my Python file in /usr/bin directory.

my Python 3.7 is actually installed in /home/pi

then I tried to change the alias command to this directory, but it fail to set as default as well.

does anyone came across this issue? I just want to change my default Python.


It is inadvisable, and violates the recommendation in PEP 394 to make python refer to python3.

Doing so (by ANY means) risks breaking your system and any tools which use python2 are likely to fail.

If you want to use python3 invoke it with python3.

If you want to install Python 3.7.2 in addition to the default Python 3.5.3, by all means use update-alternatives BUT change python3 NOT python. The differences between the 2 Python3 versions are small (see https://docs.python.org/3.7/whatsnew/changelog.html#python-3-7-3-final)

| improve this answer | |
  • Hi, thanks for your advice, i think what you say might happening to me because my apps now unable load and showing segmentation fault. but my apps is develop base on Python 3.7 and I already installed the Python 3.7 refer to the blog that i mentioned. May I know what is your advice now? – alpha91 May 15 '19 at 5:57
  • I have never installed Python from source, but if you followed normal install procedure it would NOT be in /home/pi most probably /usr/local/bin. If you undo the update-alternatives and ensure /usr/local/bin is on your path (which should be default) it should work. – Milliways May 15 '19 at 8:21
  • Hi, I get what you mean. I just checked with the command sudo update-alternatives --config python realize all the python should install in /usr/local/bin. i tried run my application with python 2.7, it is laggy able to run. but when i run with python 3.7 using command python3 script.py , it is having segmentation fault still... any idea on this? – alpha91 May 16 '19 at 2:19

Sorry, I just found the answer from another thread

Default Python version

I changed the command to the following

update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 2

Sorry all. have a nice day

| improve this answer | |
  • Thanks for answer. Some time ago I tried to install Python 3.7.x, but ended up in a mess, and I needed to create a new SD image card. I got into trouble because I am a linux newbie and do not know the idea of "dot/" to find a file . Another trouble is that I don't know the idea of "aliases" which is filename but could not find the file in that directory, because is virtually linked to somewhere I don' t know how to find. I did try to study about “alisis" but that is too difficult for newbies. Eventually I decided to upgrade my python 3.5.3 which comes with stretch and is very stable. – tlfong01 May 15 '19 at 3:26
  • you are most welcome... i see. i am a newbie now too. lol... facing another issue when launching my apps, it shows segmentation fault. read another thread say it is file corrupted. omg.... – alpha91 May 15 '19 at 3:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.