2

The odds of this question being asked are very high, but I cannot find an answer that works for me. I am in a bash shell trying to set my python 3 version (Which I installed with homebrew) to my PATH such that when I run python it goes straight into python3

python --version
Python 2.7.18
python3 --version
Python 3.9.10
which python
/usr/bin/python
which python3
/usr/bin/python3
Jack Armstrong
  • 1,182
  • 4
  • 26
  • 59
  • 1
    If `python3 --version` works then it is already in your PATH. – khelwood Feb 14 '22 at 23:24
  • Updated the question. Sorry. Trying to alias python to be python3 – Jack Armstrong Feb 14 '22 at 23:28
  • 1
    Sounds like I'm being pedantic, but what exactly does *when I run python* mean? is that you typing `python` on the terminal? Is that in a shell script? Is that what an editor, say `vscode` "sees"? Are you using a virtualenv? Depending on what you want to do, `alias python='/usr/bin/python3'` might do the trick Virtual environments also typically *"find the correct python"* themselves. I use https://github.com/brettcannon/python-launcher but only since recently. Before that I had a python alias via `alias py="python3.8"` - not specifying the entire path allows virtualenv to do its thing – JL Peyret Feb 15 '22 at 00:05
  • I'd try a `alias python='python3'` in `~/.profile` and see what that gets you. That leaves macos itself blissfully unaware of any impact to system python. – JL Peyret Feb 15 '22 at 00:07
  • See [About .bash_profile, .bashrc, and where should alias be written in?](https://stackoverflow.com/q/902946/4154375). – pjh Feb 15 '22 at 00:23
  • This is not a direct answer to your question, but in case you're not aware of it; is [```pyenv```](https://github.com/pyenv/pyenv) an option? – jrbergen Feb 15 '22 at 00:26
  • @JLPeyret thanks , fully qualified path works! – not 0x12 Aug 02 '22 at 20:57

0 Answers0