Tutorials, Python

Run Python 3 as default when Python 2 is installed on a Mac

I’ve started to learn Python version 3 I had Python 2 already installed so when typing ‘python’ in terminal python 2 was being executed. To run 3 I had to type python3 while that works I would prefer to run 3 as default. This can be done by creating an alias.

First open your bash profile:

nano ~/.bash_profile

This will open the profile if it exists, otherwise it will create it.

Next create the alias so when ‘python’ is typed python3 will be executed:

alias python='python3'

Save the file by pressing ctrl + x and y to confirm the changes, you may need to restat terminal for the alias to be available.

This allows Python 3 to be ran by default without touching Python 2.

David Carr

David Carr

For the past 12 years, I’ve been developing applications for the web using mostly PHP. I do this for a living and love what I do as every day there is something new and exciting to learn.

In my spare time, the web development community is a big part of my life. Whether managing online programming groups and blogs or attending a conference, I find keeping involved helps me stay up to date. This is also my chance to give back to the community that helped me get started, a place I am proud to be apart of.

Besides programming I love spending time with friends and family and can often be found together going out catching the latest movie, staying in playing games on the sofa or planning a trip to someplace I’ve never been before.