So I am trying to change my python default version to 3.5.2 or any 3 in general. I am running Gnu/Linux Mint 18 Cinnamon.

My OS came preinstalled with 3.5.2(I'm sure most do these days)

So if I try to change it using

alias python=python3

Using alias

However now if I exit the terminal and check the default again it hasn't changed.

Default hasn't changed

The main reason I need to change python default is for running it in a text editor like atom or sublime where I need to use version 3.

I cant seem to change it there so by build systems so this seems to be the only way.

[Please do redirect me somewhere else if this dosent belong here, but as far as I can tell its a linux issue not a texteditor issue.

  • This question is very clear, so why the down votes? – ctrl-alt-delor Apr 20 '17 at 15:37
  • Can you replace the images with text? This is the only issue I see with the question. We don't like pictures of text, when text could be used. It makes if hard to read my blind-people and machines. – ctrl-alt-delor Apr 20 '17 at 15:41

To do what you are trying you should but the alias into the file ~/.bashrc. This file is loaded and run every time bash is run. You have to put aliases in here (if you want them to persist), as they are not saved when you type them into a shell.

However this is not the best way to do it; aliasing replacements for commands usually ends in pain.

What you should do is add as the first line of your python scripts, that are written for python3, the following.

  • Oh. isnt there a better way? when i was on windows i didnt have to do anything. 3 was the default. oh well. thanks! – Ronnie Dsouza Apr 20 '17 at 16:50
  • You can do this on Unix as well (1st paragraph of answer). However it is better to specify the interpreter at the top of the program. You can then run the program by just doing ./the_program, instead of python the program, that way a user does not need worry what language it is written in. Therefore also no file extension (.py). Imagine you have a script that runs a purl program, then you rewrite the program in python, no need to change script; The program could be written in anything (python, purl, C, C♯, javascript ). Unix can do it the windows way, but there is often a better way. – ctrl-alt-delor Apr 20 '17 at 21:53

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.