2016年3月17日 星期四

Set up shortcut for python compiler -- .bashrc

It's sometimes annoying when you use python compiler.  Especially you went to some spicily complier.

I used to use python3.4 for my code. but it's not quite fast to type the whole name.

My default python version is Python 2.7.10

[check]

                                                                       
$ python --version                                     
                                                                         







ps: python2.7 是官方認可的最後版本,也是version 2中最終版本。基本上mac系統中都已經內建python系統。

Although use aliases for changing is helpful, once you close terminal or environment , the aliases before you set up will be gone.

More information about 'alias" please check 指令別名設定 -- BASH

So add alias in file-- .bashrc is a key to change environment that you don't need to set up every time at first time opening terminal.

[1. First ]

Find the location and See what python binary executables you have.

                                                                 
$ ls /usr/local/bin/python*                
                                                                  








choose and copy the the complier which you want

[2. Second]

open (or create) the .bashrc file

here i already have this file, so just need to open it.

                                                                                           
$ vi ~/.bashrc                                                                  
                                                                                            

Add new alias to change your default python executable:

                                                                                            
alias = py3='python3.4'                                                
                                                                                            








leave the file and source the file:

                                                                                            
$ . ~/.bashrc                                                                    
                                                                                            

check the version:













Reference: How to change from default to alternative Python version on Debian Linux