Post

How to Install Miniconda on macOS

Learn how to install Miniconda on macOS to manage multiple Python versions and packages.

How to Install Miniconda on macOS

Python is essential for automation, scripting, and data science. To manage Python environments and packages efficiently, Miniconda is a great tool. It allows easy switching between Python versions and managing dependencies based on project needs.

Why Choose Miniconda?

Miniconda is a minimal installer for Conda, a versatile package manager. Unlike Anaconda, which comes with many scientific tools, Miniconda provides just the essentials. It’s lightweight, fast to install, and perfect for managing Python environments without unnecessary extras.

1. Installing Miniconda on macOS

Option 1: Using the Official Installer

  1. Visit the Miniconda download page.
  2. Select the installer matching your system:
    • Apple Silicon (M1/M2/M3): Download the Apple M1 pkg installer.
    • Intel-based Macs: Download the x86_64 pkg installer.
  3. Run the installer and follow the on-screen instructions. Default settings work fine.

Option 2: Using the Command Line

For Apple Silicon:

1
2
3
4
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh

For Intel-based Macs:

1
2
3
4
mkdir -p ~/miniconda3
curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh

Post-Installation Setup

  1. Activate Miniconda:
1
source ~/miniconda3/bin/activate
  1. Initialize Conda for all shells:
1
conda init --all
  1. Restart your terminal or run:
1
source ~/.zshrc

2. Managing Python Environments

Creating a New Environment

1
conda create --name myenv

Activating the Environment

1
conda activate myenv

Installing Python and Packages

1
conda install python numpy matplotlib

Conda handles dependencies automatically.

3. Using Pip with Conda

Some packages are only available via Pip. Inside your Conda environment:

1
pip install <package-name>

4. Managing Environments

Deactivating the Environment

1
conda deactivate

Listing All Environments

1
conda info --envs

Removing an Environment

1
conda remove --name myenv --all

With Miniconda, you can efficiently manage Python environments for data science, web development, or automation. Keep your projects organized and dependencies under control with ease.

This post is licensed under CC BY 4.0 by the author.