How to set alias for python3 on OSX

11,028

When I run python I get -bash: “python3”: command not found

Why are you using and (smart quotes) instead of ' (normal single quotes)?

Try the following (corrected) .bash_profile

# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
alias python='python3'
alias 3='python3'
alias py='python3'

Further Reading

Share:
11,028

Related videos on Youtube

Noah Kiss
Author by

Noah Kiss

Updated on September 18, 2022

Comments

  • Noah Kiss
    Noah Kiss over 1 year

    I'm trying to set an alias for python3 so I can run it with python.

    Here's my current .bash_profile

    # Setting PATH for Python 3.6
    # The original version is saved in .bash_profile.pysave
    PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
    export PATH
    alias python=“python3”
    alias 3=“python3”
    alias py=“python3”
    

    When I run python I get -bash: “python3”: command not found.

    I can run python3 and it will correctly open py 3.X.X (3.6.1 at time of posting).

    There are plenty of half-answers over the years on here & SO, and a few comments mentioning my issue, but hopefully this can be a resource for a complete answer. Or maybe one of you is better at googling than I am and it can be a duplicate question!

  • Noah Kiss
    Noah Kiss about 7 years
    Thanks, I saw your comment and fixed the issue. Marked as correct answer. Stupid case of using open after not seeing results using nano (because I didn't open a new instance)