Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

"-bash: brew: command not found" for all "brew" commands after installing Homebrew

I had a similar issue with my PATH in https://discussions.apple.com/thread/253548744, which I thought was fixed but I have since installed Homebrew and having a similar problem. All commands such as brew help return:

-bash: brew: command not found

I am not sure of the correct PATH for brew or what to change

Mac mini, macOS 10.15

Posted on Jan 10, 2022 10:59 AM

Reply
Question marked as Best reply

Posted on Jan 11, 2022 9:05 AM

If you have Python 3.9 installed via brew (or Python.org) the following PATH change will find Python 3.9, the homebrew binary, and your normal system binaries:


export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:${PATH}"


This happens to be my own PATH setting for Bash and Zsh.


You cannot grep a dot directory as you observed. Also note, that there will be links in /usr/local/bin to the Python binaries in that Python framework.

9 replies
Question marked as Best reply

Jan 11, 2022 9:05 AM in response to DeadScorpion

If you have Python 3.9 installed via brew (or Python.org) the following PATH change will find Python 3.9, the homebrew binary, and your normal system binaries:


export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:${PATH}"


This happens to be my own PATH setting for Bash and Zsh.


You cannot grep a dot directory as you observed. Also note, that there will be links in /usr/local/bin to the Python binaries in that Python framework.

Jan 11, 2022 8:49 AM in response to BobHarris

Sorry, I don't know which one is the incorrect file:


/Users/<username>/.bash_profile:PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

/Users/<username>/.bash_profile:export PATH=/usr/bin:/bin:/usr/sbin:/sbin

/Users/<username>/.bash_profile.save:PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

/Users/<username>/.bash_profile.save:export PATH=’/usr/bin:/bin:/usr/sbin:/sbin

/Users/<username>/.bash_profile.save.1:PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"

/Users/<username>/.bash_profile.save.1:export PATH=/usr/bin:/bin:/usr/sbin:/sbin

grep: /Users/<username>/.bash_sessions: Is a directory

grep: /Users/<username>/.cache: Is a directory

grep: /Users/<username>/.config: Is a directory

grep: /Users/<username>/.cups: Is a directory

grep: /Users/<username>/.idlerc: Is a directory

grep: /Users/<username>/.oracle_jre_usage: Is a directory

grep: /Users/<username>/.viminfo: Permission denied

grep: /Users/<username>/.vscode: Is a directory

Jan 11, 2022 11:48 AM in response to VikingOSX

Thanks,

I am not sure what you mean. I use the pre-installed version of python and I changed this PATH but it did not work. Was I supposed to replace the line PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}" with:

export PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:${PATH}"?

I also found that when installing Homebrew, it gave the warning:

Warning: /usr/local/bin is not in your PATH.

I don't know if this is significant or not

Jan 11, 2022 12:23 PM in response to DeadScorpion

You do not need a PATH statement that includes that Python 3.9 entry when using the default Python 2.7.16 on Catalina. Just do this:

export PATH="/usr/local/bin:${PATH}"



and depending on your shell:


source ~/.bash_profile
source ~/.zshrc


to make that PATH effective in the current Terminal session.


Not only does this now give you access to brew, but also that /usr/bin/python that is linked to its bin directory in the System's Python.framework.


However, some brew-installed packages may have a dependency on Python3 and brew will attempt to install it in /usr/local/bin with links to that /Library/Frameworks/Python.framework.../3.9/bin location. This does not matter unless you attempt to use Python3 or idle3.

Jan 11, 2022 1:45 PM in response to DeadScorpion

A few things.


If you have switched over to zsh, as VikingOSX has implied, then your .bash_profile is not going to be executed, unless you either transfer the important stuff over to the appropriate zsh initialization script, or you source your .bash_profile from one of your zsh initialization scripts.


In your .bash_profile you have 2 export PATH statements

/Users/<username>/.bash_profile:PATH="/Library/Frameworks/Python.framework/Versions/3.9/bin:${PATH}"
/Users/<username>/.bash_profile:export PATH=/usr/bin:/bin:/usr/sbin:/sbin


The 2nd one totally undoing what the first one did. So in theory you have a valid PATH, but it does not include the Homebrew directory. Again VikingOSX has suggested a solution for that.


Mostly, I'm saying what VikingOSX is saying, only different 😀

"-bash: brew: command not found" for all "brew" commands after installing Homebrew

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.