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?

asked Dec 3, 2022 at 0:41
10
  • What is the output of type python3? echo $PATH? hash python3? Does it persist after hash -r? Commented Dec 3, 2022 at 0: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 Commented Dec 3, 2022 at 0:46
  • @KamilCuk after running hash python3 and hash -r all got consistent. Commented Dec 3, 2022 at 0:48
  • @KamilCuk, if hash thing is related to that inconsistency, I think posting an answer with more clarifications would be great :) Commented Dec 3, 2022 at 0:56
  • 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 Commented Dec 3, 2022 at 1:09

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.