MacOS下安装Conda/Anaconda的最佳方法及conda命令报错解决方案
在macOS上安装Conda的最佳方式与常见问题解决
Hey there! Let's break down the best ways to get Conda up and running on your Mac, plus fix that annoying "command not found: conda" issue you're hitting after using Homebrew.
最佳安装方式:Miniconda(强烈推荐)
Most folks don't need the full Anaconda distribution (it comes with hundreds of pre-installed packages you'll never use), so Miniconda is the way to go—it's lightweight, flexible, and avoids most path-related headaches. Here's how to install it:
- Head to the official Conda website and download the Miniconda installer matching your Mac's architecture (Intel or Apple Silicon).
- Double-click the
.dmgfile and follow the installation wizard. When you get to the "Installation Type" step, make sure to check the box that says "Add Miniconda3 to my PATH environment variable"—this is critical to avoid the "command not found" error later. - Once installation finishes, open a new Terminal window (important, don't reuse the old one) and run
conda --version. If you see a version number, you're good to go!
解决Homebrew安装后找不到conda的问题
When you install Anaconda via brew cask install anaconda, Homebrew puts it in a standard location but doesn't automatically add it to your system's PATH. Here's how to fix that:
- First, find where Homebrew installed Anaconda. Run this command in Terminal:
Look for a line that says something like "Executable script: /usr/local/anaconda3/bin/conda" (for Intel Macs) or "/opt/homebrew/anaconda3/bin/conda" (for Apple Silicon).brew info anaconda - Next, add this path to your shell's configuration file:
- If you're using zsh (the default shell on modern macOS), open
~/.zshrcin a text editor (likenano ~/.zshrc) and add this line at the bottom:export PATH="/usr/local/anaconda3/bin:$PATH" # Replace with your actual path from step 1 - If you're using bash, edit
~/.bash_profileor~/.bashrcinstead with the same line.
- If you're using zsh (the default shell on modern macOS), open
- Save the file and apply the changes immediately by running:
source ~/.zshrc # Use source ~/.bash_profile if you're on bash - Now test it out: run
conda --version—it should show up without errors!
总结推荐
- First choice: Use the official Miniconda installer. It's the most reliable method and handles PATH configuration automatically if you check that box during setup.
- If you prefer Homebrew: Just remember to manually add the Anaconda bin directory to your PATH as outlined above.
内容的提问来源于stack exchange,提问作者Joe




