41

What is the recommended approach for installing Anaconda on Mac?

I tried with brew cask install anaconda
which after a while returns anaconda was successfully installed!.

After that - trying conda command returns command not found: conda.

Is there any post step installation that needs to be done?
And what is recommended way to install Conda on MacOS?

5
  • 1
    That is because conda is currently not added to the PATH, check if the conda is present in the PATH, if not, add it.
    – Daksh
    Mar 5, 2018 at 19:57
  • to add to Daksh's comment that should be added automatically when you do conda init <SHELL NAME> e.g. conda init bash Mar 28, 2020 at 15:16
  • why did you not accept the answer that linked to the official installation? How is the other answer superior for your use case? Mar 28, 2020 at 18:23
  • 1
    Just follow the official documentation: docs.anaconda.com/anaconda/install/mac-os.
    – AMC
    Mar 30, 2020 at 22:56
  • why would you accept an answer that doesn't use the official installation package for mac anaconda.com/products/individual? Jun 16, 2021 at 22:17

5 Answers 5

49
  • brew install anaconda

The run which anaconda to find the path to export.

  • export PATH="/usr/local/anaconda3/bin:$PATH"

For Mac M1

  • export PATH="/opt/homebrew/anaconda3/bin:$PATH"
7
  • 2
    shouldn't the people be doing conda init <SHELL NAME> than adding it directly to the path like you suggested? conda init seems to add other stuff too besides just the path... Mar 28, 2020 at 15:18
  • 1
    why did you choose to not use an official installation process e.g. anaconda.com/distribution ? Mar 28, 2020 at 15:21
  • 12
    I had to do brew install --cask anaconda Jul 15, 2021 at 23:34
  • 29
    For MAC M1 - export PATH="/opt/homebrew/anaconda3/bin:$PATH"
    – neoswf
    Jun 10, 2022 at 14:38
  • 3
    brew cask is no longer a brew command. I only used brew install anaconda
    – YouQam
    Jun 28, 2022 at 13:47
8

I would say that the recommended way to install anaconda is to use the official anaconda installer, which can be downloaded from the link I just posted. I've done it several times, never had a problem, and it walks you through it (including an option to automatically add it to your PATH).

1
  • I've had issue where conda decides to install itself at ~/opt when using the dmg/graphi installer. I do not know why that happens. Did you ever have that problem? Mar 28, 2020 at 15:18
3

New answer using only the terminal for mac zsh

This is how I did it only using the terminal and apple's now default zsh:

# - install python
# install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#  install wget to get miniconda
brew install wget

# get miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O ~/miniconda.sh
bash ~/miniconda.sh -b -p $HOME/miniconda

# source /Users/my_username/opt/anaconda3/bin/activate
source ~/miniconda/bin/activate
conda init zsh
conda update -n base -c defaults conda
conda install conda-build

conda create -n iit_synthesis python=3.9
conda activate iit_synthesis
#conda remove --name metalearning2 --all

inspired from: How do I use Conda in on Homebrew Python system?


Old answer

I don't know about other people but I've had issue downloading conda/miniconda etc for a few hours now. For some reason it decided to install at ~/opt when using the graphical installer (i.e. the .dmg file). I've been through the uninstall here How to uninstall Anaconda completely from macOS and additionall did an rm -rf ~/opt command. Seems that without this its not actually uninstalled (you might also have to change your PATH or .bash_profile or .bashrc until your path is virigin again before you start your re-installation installation). Seems that using the command line installer is what works:


Anaconda3 will now be installed into this location:
/Users/brandBrandoParetoopareto/anaconda3

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/Users/brandBrandoParetoopareto/anaconda3] >>> 
PREFIX=/Users/brandBrandoParetoopareto/anaconda3

Unpacking payload ...
Collecting package metadata (current_repodata.json): done                                                                                                                                                                                                                                                                                            
Solving environment: done

So for that download it from the official link then do:

sh Anaconda3-2020.02-MacOSX-x86_64.sh 

do sh I believe is the right thing because I might have had issue in the past when I did bash instead...plus if you are using a different shell like zsh I am not sure what you'd need to do, but I'd get sh would be safest.

After the installation is done you should do:

conda init <SHELL-NAME>

so that conda is initialized correctly (so far that seems to only modify my .bash_profile and my PATH variable). Unfortunately, it seems the previous uninstallation attempts didn't remove the code the previous conda init had added from my .bash_profile so I removed it manually using vim.

This is what I get after doing that:

conda init bash

no change     /Users/brandBrandoParetoopareto/anaconda3/condabin/conda
no change     /Users/brandBrandoParetoopareto/anaconda3/bin/conda
no change     /Users/brandBrandoParetoopareto/anaconda3/bin/conda-env
no change     /Users/brandBrandoParetoopareto/anaconda3/bin/activate
no change     /Users/brandBrandoParetoopareto/anaconda3/bin/deactivate
no change     /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.sh
no change     /Users/brandBrandoParetoopareto/anaconda3/etc/fish/conf.d/conda.fish
no change     /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/Conda.psm1
no change     /Users/brandBrandoParetoopareto/anaconda3/shell/condabin/conda-hook.ps1
no change     /Users/brandBrandoParetoopareto/anaconda3/lib/python3.7/site-packages/xontrib/conda.xsh
no change     /Users/brandBrandoParetoopareto/anaconda3/etc/profile.d/conda.csh
modified      /Users/brandBrandoParetoopareto/.bash_profile

==> For changes to take effect, close and re-open your current shell. <==

if you are using vs-code integrated terminal like I am you need to press the trash can button. Doing bash seems to NOT re-run your .bash_profile so make sure you do what it would consider "closing your terminal and re-opening it completely".

That should be all you need to do I believe. Perhaps you also need to make sure you have the most recent version of mac OS.


Extra tips hints

  • Make sure conda init modified your .bash_profile correctly. For me for some reason it added it's stuff AFTER it ran my .bashrc and thus when my .bashrc tried activating my environment it wouldn't do it as it would say conda wasn't initialized correctly (and thus nio matter how many times I re-ran conda init <SHELL> it wouldn't fix it. I don't know why that happened but that's how it was.

  • I avoided the dmg/graphical installation since it seemed to install it at non-standard places ~/opt

  • If conda is still acting weird it might be because of the way your .bashrc modifies the PATH env variable. What worked for me was removing lines that modified my path in .bashrc (AND having the code conda init added before my .bashrc was ran).


inspired from:

0

After installation using the graphical installation, everything sits in the ~/opt directory, as mentioned in some previous answers. If this is OK for you, all you need to do to use the command line conda is add ~/opt/anaconda3/bin in your path. This can be done by adding

export PATH="${PATH}:~/opt/anaconda3/bin"

at the end of your rc file (~/.zshrc or ~/.bashrc).

0

The directory path of your conda installation can depend on various factors, hence copy pasting directories and asking them to export that as their paths might not work. Do this instead:

$ brew install -cask anaconda
$ cat ~/.conda/requirements.txt
/example/directory/anaconda3
$ export PATH="/example/directory/anaconda3/bin:$PATH"
$ conda --help
usage: conda [-h] [--no-plugins] [-V] COMMAND ...

conda is a tool for managing and deploying applications, environments and packages.

options:
  -h, --help          Show this help message and exit.
  --no-plugins        Disable all plugins that are not built into conda.
  -V, --version       Show the conda version number and exit.
.
.
1

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.