Setting Up Data Science Development Environment on Apple M1/BigSur

June 8, 2021

Apple’s latest M1/BigSur Macbook has created many troubles for data science professionals when it comes to building basic data science libraries or even basic things like installing different versions of Python. Today, we compile a list of work-arounds that we have tested and proved to be working:

Install and Manage Python 3.8 with Pyenv:
Source: https://github.com/pyenv/pyenv/issues/1768

pyenv install --patch 3.8.7 <<(curl -sSL https://raw.githubusercontent.com/Homebrew/formula-patches/9811be33170a8f31a684fae6955542e31eb4e61e/python/3.8.7.patch) 

Build Pandas/Numpy with Homebrew:
Source: https://github.com/numpy/numpy/issues/17784

brew install openblas
OPENBLAS="$(brew --prefix openblas)" pip install numpy pandas

Build Pandas/Numpy within Docker Container without Homebrew:

  • Right click the terminal app within the Utilities folder of your Applications folder. And then click Get Info on the menu and select the “Open using Rosetta” option.
  • In your terminal, type the following command to switch to the intel chip mode:
arch -x86_64 zsh
  • In your Dockerfile, you can add the following command:
RUN pip install cython numpy pandas
  • Then build your docker image with a newly opened terminal (under Rosetta).

Build Pandas without Homebrew (This Method Doesn’t Work within Docker)
Source: https://stackoverflow.com/questions/65084318/trouble-installing-pandas-on-new-macbook-air-m1

pip install numpy cython
git clone https://github.com/pandas-dev/pandas.git
cd pandas
python3 setup.py install

Hopefully this will be able to smoothen your journey of adopting the Macbook M1/BigSur as a data science professional. Thanks!