How to set alias for python3 on OSX

2

1

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

Posted 2017-04-02T20:27:04.650

Reputation: 23

You shouldn't correct the code in the question as it will confuse future readers. I've rolled back the changes. – DavidPostill – 2017-04-02T20:49:33.950

Answers

4

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

DavidPostill

Posted 2017-04-02T20:27:04.650

Reputation: 118 938

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) – Noah Kiss – 2017-04-02T20:48:34.257