How to set default Python version in OS X

Today I ran into the trouble as most of my scripts were failing due to version mis match. The code I had written was Python 3.x compatible but my system had by default set Python2.x as the default version. Following are the steps which i followed to fix the problem:

    • Open ITerm. ( You can use your default mac terminal also.)
    • Open your ~/.bash_profile in vim or any other text editor.
    • Add alias python='python3'
    • Save the file
    • Run source ~/.bash_profile
  • Now try running python -version to see which version is coming up

Let me know in comments if you fail to follow above steps.


2 thoughts on “How to set default Python version in OS X

  1. Not a fare thing to do by altering the python version. You should not change the version as your system has dependencies on several python executables running on your machine. If you want to implement your programs and executables on python3 install python virtual environment. Install python3 in your python virtual environment and you can carry your executions inside the python virtual environment itself. It’s easier to implement and does not have the dependency on your system


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s