Python

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.

Advertisements