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
- An A-Z Index of the Bash command line for Linux - An excellent reference for all things Bash command line related.
- alias - Create an alias, aliases allow a string to be substituted for a word when it is used as the first word of a simple command.
Related videos on Youtube
Author by
Noah Kiss
Updated on September 18, 2022Comments
-
Noah Kiss over 1 year
I'm trying to set an alias for
python3
so I can run it withpython
.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 openpy 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 about 7 yearsThanks, I saw your comment and fixed the issue. Marked as correct answer. Stupid case of using
open
after not seeing results usingnano
(because I didn't open a new instance)