I had installed Python 3.7 according to the tutorial in this blog post (I changed the Python version to 3.7.2):

Building Python 3.6 on Raspberry Pi 3 from sources (clean Debian)

However, when I checked my default Python executable with

python --version

it was still showing the 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 checked my Python version, it showed an error which cannot found my Python file in the /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 failed to set as default as well.

How can I fix this?

I just want to change my default Python interpreter.

3 Answers 3


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)

  • 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
    Commented May 15, 2019 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
    Commented May 15, 2019 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
    Commented May 16, 2019 at 2:19

Based on the question Default Python version, I changed the command to:

update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 2
  • 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
    Commented May 15, 2019 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
    Commented May 15, 2019 at 3:36

Worth noting that the accepted answer above by @Milliways is now out of date:

As of 2019, activating a Python virtual environment (or its functional equivalent) prior to script execution is one way to obtain a consistent cross-platform and cross-distribution experience.

They also state that it is acceptable to point python to python3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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