2

After installing Anaconda, "~/anaconda/bin" was added to the $PATH variable. But now, I cannot run "brew":

-bash: brew: command not found

Only if I add "usr/local/bin:usr/local/sbin" to the beginning of $PATH can I get brew to work, but then I don't have the Anaconda python installation.

How can I have a default Anaconda python and and operational homebrew?

BolzanoW
  • 665
  • 1
  • 6
  • 12

4 Answers4

2

I think the problem is that your PATH is now mis-configured. What is your PATH and also the contents of .bash_profile? Ensure that you can access both via PATH with any mods in .bash_profile.

Also, I am wondering how many versions of Python you have installed? If the Anaconda installation came with a version of Python, then perhaps the version that homebrew installed should be uninstalled.

See Is path broken for anaconda ipython? and How to modify PATH for Homebrew?

Community
  • 1
  • 1
harymitchell
  • 155
  • 7
1

Maybe a softlink to ~/anaconda/bin/python in /usr/local/bin would do the trick. The problem I guess would be caused by conflicting python versions, so a soft link in the preferred directory would work. Furthermore, if you want to avoid overwriting the existing python in /usr/local/bin add a soft link in ~/.local/bin instead.

0

A possible work around for the situation where you want both commands available would be to set aliases. i have done this as follows in my .bash_profile on Mac OS X. You will have both paths set but with differing commands.

# added by Anaconda 2.3.0 installer
#export PATH="/Users/macuser/anaconda/bin:$PATH"
alias pythonA="/Users/macuser/anaconda/bin/python"
alias conda="/Users/macuser/anaconda/bin/conda"

What this did was comment out the default path prepend that Anaconda will do on install. now if you run "pythonA" it will use Anaconda. You will stil need the brew path.

John Morrison
  • 3,810
  • 1
  • 15
  • 15
0

November 2021, M1 Macbook Pro, MacOS 12.0.1 Monterey using bash, Anaconda Navigator 2.1.1 installed from the GUI installer not brew. Seems like it'd work with zsh too.

Try their code required at the end of the install process to re-add Brew back to your PATH. Replace USERNAME with your profile name as seen in a finder window.

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/USERNAME/.bash_profile
eval "$(/opt/homebrew/bin/brew shellenv)"

To solve I reinstalled Brew as on their website without removing or uninstalling Brew or Brew files which tells you to do the above commands anyway.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

There probably some housekeeping and efficiency stuff experienced users might do or recommend but I'm not that knowledgeable and this worked for me. I just wanted to post an update for M1 people.


I noticed I was working in the (base) environment in terminal and just considered that wasn't working the same as regular termial.

Discussion on removing base env and text only According to this post, base is activated by default so you have two options. (1) configure PATH for the base environment with all the missing pieces your normal PATH has or (2) deactivate base

(1) is for more googling others' answers but you can start with export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" to get most of the basic functions.

(2) turn off the (base) environment each time with conda deactivate or disable its default activation with conda config --set auto_activate_base false

Alex
  • 1
  • 1