As of July 2021, installing Python Xgboost on the M1 Macs is still confusing. The Python Xgboost library relies on Scipy, which requires a Fortran compiler, which is not available because GCC is not yet available for M1 (while Scipy does not support Flang). You may succeed in installing Python xgboost library without doing what I have described below and yet encounter issue running the library. I find the easiest thing currently is to just run Terminal with Rosetta, and go from there...
- Navigate to the Terminal app in Applications folder (sometimes it might be in Applications/Utilities)
- Right click on the
Terminal
app -> Get Info -> CheckOpen using Rosetta
- Optionally, you can duplicate the Terminal app, and rename the new one to something different, such as
Terminal Rosetta
and only make the duplicated app run in Rosetta mode
If you have a previous installation of brew, you can uninstall by:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
With the Terminal
app running in Rosetta mode:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will install brew, and since we are in Rosetta mode, you should see brew being installed under /usr/ directory. If it is being installed under /opt/ direcotry, it means you are installing a version of brew that's natively compiled for M1 chip, which is not what we want here.
brew install postgresql miniforge cmake libomp git-lfs
git lfs install
conda init zsh
Open a new Terminal window and start installing the rest.