Setting up M1 mac without homebrew

Lu Wang
2 min readDec 11, 2020

Recently, I got my new macbook with the M1 chip and I was excited to try out the new features — one of them being using the new version of tensorflow that takes advantage of the new chip. To setup Python so that I can try out this mac, the top ones I need are: numpy, tensorflow, matplotlib, pandas, sklearn.

Of course, before installing anything the very first thing I checked was homebrew. After finding out homebrew has not yet supported the M1 macs yet, I was left with two options 1) get the source and install the dev version with ARM support or 2) install with Rosetta.

I can’t decide which route I wanted to take for that moment so I decided to temporarily fly without homebrew. The good news is that when I got this version of Tensorflow for the M1 chip, it also comes with Numpy. 2/5 tasks completed! I was able to quickly test out some Tensorflow examples on my new mac and the performance was awesome comparing to my old mac.

Then I wanted to make some basic plots and then I realized matplotlib cannot be installed without it’s dependency Pillow and Pillow requires libjpeg. Again, as a consequence of my decision to fly without homebrew, I know it’s going to be bumpy. And I decided to install libjpeg from source rather than simply `brew install libjpeg`.

So I first downloaded the source code for libjpeg.

cd jpeg-9c
./configure --prefix=/usr/local/include
make
make install

Set the paths right

export LDFLAGS="-L/usr/local/include -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
export CPPFLAGS="-I/usr/local/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

Then pip install Pillow and matplotlib ran smoothly without any problem.

I still left with pandas and sklearn on my list but I am able to further try out tensorflow on my mac and visualize some results without any problem for now.

--

--