Make Python version xx as default

Categories:   web development  
Tags:   python  

How to run a specific version of python with just ‘python’ instead of something like ‘python3.7’.

We’ll use version 3.7 in this example.

Check Python version

After you have python installed, check the version:

$ python3.7 -V

Make Python 3.7 the default python version

Check the path python3.7:

$ which python3.7
/usr/local/bin/python3.7

Create an alias for this path:

$ vim ~/.bashrc

Add the following alias to the file & save:

alias python='/usr/local/bin/python3.7'

Reload bashrc:

source ~/.bashrc

Check the python version again

$ python -V
$ Python 3.7.0

Now we don’t have to type python3.7 everytime but just python.

Related Products



Categories:   web development  
Tags:   python