How to install libjpeg on OSX?

Using Homebrew:

brew install jpeg

Fresh install of Big Sur (macOS 11.0.1) and Homebrew, then :

brew install jpeg

Then installed XCode command line tools (required because of zlib) via

xcode-select --install

Then in zsh for tools to find headers :

export CPATH=`xcrun --show-sdk-path`/usr/include
export LDFLAGS="-L//Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
export CPPFLAGS="-I//Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"

Lastly in a virtual environment (Python 3.8) :

pip install setuptools, wheel, Pillow

For libjpeg-turbo

 brew install jpeg-turbo

Then it'll give you instructions on how to add it to your library load path (so that it doesn't conflict with libjpeg, it isn't in the standard paths).