0

Trying to install python3 with brew install python3. Prior to this I have added and sourced the ~/.zshrc file (created by me, it was absent by default) containing:

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
(OR)
export PATH=/usr/local/bin:$PATH

But the output of which python3 is always /opt/homebrew/bin/python3. I would like to have the output as /usr/local/bin/python3

Immediately after the installation of brew I ran the following commands as it was instructed in the terminal

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

I also tried uninstalling brew and then a fresh installation followed by not running the above commands but the output of which python3 is same

7
  • 2
    How did you get python3 into /usr/local/bin? Is your machine Apple Silicon or Intel? What is your default shell? Why are you running the last set of commands?
    – mmmmmm
    Jun 13, 2022 at 15:52
  • I didn't get the python3 into /usr/local, I would like to have it that way. My Chip is Apple M1 pro and my shell is zsh (The prompt starts with % ). The last set of commands I had to run as it was instructed when I installed brew
    – Hrushi
    Jun 13, 2022 at 16:02
  • What do you want to say with "I have both runned and didn't run" in your last sentence?
    – nohillside
    Jun 13, 2022 at 16:03
  • @nohillside edited the question, my bad should have explained better.
    – Hrushi
    Jun 13, 2022 at 16:09
  • 1
    Where is your python executable?
    – mmmmmm
    Jun 13, 2022 at 16:39

1 Answer 1

5

On ARM Macs, Homebrew will always install to /opt/homebrew and put its binaries into /opt/homebrew/bin. So you need to adjust your PATH to include /opt/homebrew/bin as well.

An easy way to set all relevant PATHs is to run

/opt/homebrew/bin/brew shellenv

and add the result to the init file of your choice.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .