Pip install matplotlib fails because one of its dependencies is pillow and one of pillow’s dependency is libjpeg. The specific error is:
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
따라서 libjpeg를 설치해주면 정상적으로 matplotlib을 설치할 수 있다.
brew install libjpeg
출처: https://alexslobodnik.medium.com/apple-m1-matplotlib-python-and-jupyter-lab-551646b9a8cd