Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bparaj/6faab3969c82b68664ce3f9b9508094c to your computer and use it in GitHub Desktop.
Save bparaj/6faab3969c82b68664ce3f9b9508094c to your computer and use it in GitHub Desktop.
Install scikit-learn within a virtual Python environment on Mac (Apple Silicon M1)

Issue

I was trying to install scikit-learn with:

python3 -m pip install scikit-learn

but it failed with a ton of errors while dealing with numpy as a dependency. Main error:

clang: error: the clang compiler does not support 'faltivec', please use -maltivec and include altivec.h explicitly

Fix

https://scikit-learn.org/dev/install.html#installing-on-apple-silicon-m1-hardware suggests using miniforge.

Steps

  1. Download the correct version of miniforge binary from https://github.com/conda-forge/miniforge. In my case:
wget `https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh
  1. Run:
bash Miniforge3-MacOSX-arm64.sh
  1. Reload your shell. You can simply open a new tab or a new terminal.
  2. Create a new environment with conda
conda create --name py392
  1. Activate the created environment
conda activate py392
  1. Install the version of Python that you need within this environment
conda install -y python==3.9.2
  1. Install scikit-learn
conda install -y scikit-learn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment