Skip to content

Instantly share code, notes, and snippets.

@ryanorsinger
Last active October 17, 2024 20:31
Show Gist options
  • Save ryanorsinger/7d89ad58901b5590ec3e1f23d7b9f887 to your computer and use it in GitHub Desktop.
Save ryanorsinger/7d89ad58901b5590ec3e1f23d7b9f887 to your computer and use it in GitHub Desktop.
Installing Homebrew and Anaconda

Installing Homebrew and Anaconda on a Mac

Install Homebrew

Run the following command on your terminal to install Homebrew. Homebrew is a package manager for Macs and is used to install useful development tools and software.

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

Install Anaconda through Homebrew

  1. Run brew install --cask anaconda to install Anaconda
  2. Run echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.zshrc from your terminal
  3. Also run echo 'export PATH=/opt/homebrew/anaconda3/bin:$PATH' >> ~/.zshrc from your terminal
  4. Run source ~/.zshrc from your terminal
  5. Type conda to ensure that anaconda linked correctly.

If you use bash instead of zsh, replace steps 2 and 3 from above with the following:

  • echo 'export PATH=/usr/local/anaconda3/bin:$PATH' >> ~/.bash_profile
  • echo 'export PATH=/opt/homebrew/anaconda3/bin:$PATH' >> ~/.bash_profile
  • source ~/.bash_profile

If you've already installed anaconda from the installation file from anaconda.org

If you installed Anaconda for only this user, run the following:

  • echo 'export PATH=/Users/$USER/anaconda3/bin:$PATH' >> ~/.zshrc
  • echo 'export PATH=/opt/homebrew/anaconda3/bin:$PATH' >> ~/.zshrc
  • source ~/.zshrc

If you installed Anaconda for all users on your computer, then run the following:

  • echo 'export PATH=/opt/anaconda3/bin:$PATH' >> ~/.zshrc
  • source ~/.zshrc
@ryanorsinger
Copy link
Author

ryanorsinger commented Jul 8, 2021

If zsh users get "conda not found", then running /opt/homebrew/anaconda3/bin/conda init zsh from the terminal is apparently the way forward w/ zshell since anaconda no longer suggests modifying the path

@pablobablo
Copy link

Thanks! It was helpful.

@Dhruv-mat
Copy link

Dude thank you son much

@Danielle-786
Copy link

Thank you! Super helpful!

@najamulsaqib
Copy link

Thanks dude.

@kugla2
Copy link

kugla2 commented Jul 31, 2023

Thank you! Super helpful!

@RW-77
Copy link

RW-77 commented Aug 21, 2023

This worked, thank you so much!

@vbhavsar
Copy link

If you're using fish shell, run

fish_add_path /opt/homebrew/anaconda3/bin

@adriaanph
Copy link

actually @ryanorsinger & everybody, you should replace steps #2 - #5 with the following very simple
conda init bash
(or check out conda init if you use a different shell.

i found this page because i was struggling after installing brew & conda. the above solved all of my issues.

@AtsungC
Copy link

AtsungC commented Sep 15, 2023

Thank you !

@AlifUnseen
Copy link

actually @ryanorsinger & everybody, you should replace steps #2 - #5 with the following very simple conda init bash (or check out conda init if you use a different shell.

i found this page because i was struggling after installing brew & conda. the above solved all of my issues.

Agree. This helped me.

conda/conda#13022 (comment)

@marvitalex
Copy link

Thank you for the article!
I would also like to add that if you are using ZSH as your shell or are a Mac user with an M1, M2 chip, etc.
You need to execute the following commands (assuming that Homebrew is pre-installed):

  1. brew install --cask anaconda
  2. conda init zsh
  3. source ~/.zshrc

Then you can execute the command to update conda:

  • conda update conda

@SiriusBits
Copy link

I don't think conda init zsh will work. It needs to be initialized from the Homebrew location. In the link from @AlifUnseen I found what seems to be the correct instructions:

For people using homebrew to install anaconda (brew install --cask anaconda) instead of manually adding conda to PATH run /(your conda installation path)/bin/conda init zsh which on Apple silicon (M1/M2) is /opt/homebrew/anaconda3/bin/conda init zsh. This adds conda to your PATH in .zshrc and makes sure that you can now use conda and activate conda environments.

Then you can run source ~/zshrc and use conda in your shell.

@vOwl
Copy link

vOwl commented Dec 15, 2023

super helpful, thanks a lot 🙌

@WeiMao33
Copy link

super helpful, thanks a lot

@eugeneYWang
Copy link

While command uname -m returns arm64, brew install --cask anaconda still downloads x84_64 version of Conda instead of arm64 version. Anyone running into this issue?

@ryanjafari
Copy link

thanks

@waylchan
Copy link

thank you!

@Alex-Teodosiu
Copy link

Great! Thanks :)

@telnet2
Copy link

telnet2 commented May 12, 2024

If zsh users get "conda not found", then running /opt/homebrew/anaconda3/bin/conda init zsh from the terminal is apparently the way forward w/ zshell since anaconda no longer suggests modifying the path

thanks! this was exactly what helped me!

@sangiliarumugam
Copy link

Thanks. These post-installation steps should be added to the installation script.

@sigmapointindia
Copy link

Thanks!! this was a saviour.

@viplike
Copy link

viplike commented Aug 23, 2024

nice, thanks

@pathgeek
Copy link

Thank you. Anaconda should call you out with praise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment