1

That is what I observe in my mac, iterm2:

> /usr/bin/python3 --version
python3.8.9
> python3 --version
Python3.8.9
> `which python3` --version
Python3.10.8
> which python3
/usr/local/bin/python3

Could anyone please explain why which python3 could return a path to the executable different from the executable run by mere python3?

I messed my system a bit with too many pythons, so I was about to clean it, when I discovered this inconsistency. One of the pythons must have been installed with brew, another with conda. But shouldn't which command always return a path to the executable run by mere command?

govordovsky
  • 359
  • 2
  • 17
  • What is the output of `type python3`? `echo $PATH`? `hash python3`? Does it persist after `hash -r`? – KamilCuk Dec 03 '22 at 00:44
  • `type python3` -> `python3 is /usr/local/bin/python3` `echo $PATH` -> `/Users/foo/anaconda3/condabin:/Users/foo/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/foo/.local/bin` – govordovsky Dec 03 '22 at 00:46
  • @KamilCuk after running `hash python3` and `hash -r` all got consistent. – govordovsky Dec 03 '22 at 00:48
  • @KamilCuk, if `hash` thing is related to that inconsistency, I think posting an answer with more clarifications would be great :) – govordovsky Dec 03 '22 at 00:56
  • It could be that "python3" is a command alias in your .bashrc (or whatever mac uses). – tdelaney Dec 03 '22 at 00:57
  • run `alias` to see if python3 is there. – tdelaney Dec 03 '22 at 00:59
  • If that's the case, this is a duplicate of https://stackoverflow.com/questions/41524320/virtualenv-uses-wrong-python-even-though-it-is-first-in-path/41524530#41524530 – tdelaney Dec 03 '22 at 01:00
  • @tdelaney `alias` returns nothing – govordovsky Dec 03 '22 at 01:00
  • Strange. One usually has `ll` at the least. I am a linux user, not mac, so can't test. – tdelaney Dec 03 '22 at 01:04
  • 1
    I think @KamilCuk gave the right hint. after running `hash python3` and `hash -r` the problem disappeared, would be great to wrap it up in some answer – govordovsky Dec 03 '22 at 01:09

0 Answers0