August 03, 2019
If you ever tried to install matplotlib without using anaconda, then you probably pulled out some hair. After destroying my python environment several times, I finally figured it out. This solution only works for Mac, so sorry Linux and Windows users.
I recommend using pipenv to manage python version, because downloading python from brew was a pain in the ass when you need more than one version of python. I needed to use python 3.6, because at the time tensorflow did not support python 3.7.
$ brew update
$ brew install pyenv pipenv
$ mkdir ~/project
$ cd ~/project
$ pyenv init
$ PYTHON_CONFIGURE_OPTS=\"--enable-framework\" CFLAGS=\"-I$(brew --prefix openssl)/include\" LDFLAGS=\"-L$(brew --prefix openssl)/lib\" pyenv install 3.6.5
$ pyenv local 3.6.5
$ pipenv shell
$ python --version
$ pip3 install numpy
$ pip3 install matplotlib
import numpy as np
import matplotlib.pyplot as plt
x_data = np.linspace(0, 10, 10) + np.random.uniform(-1.5, 1.5, 10)
y_data = np.linspace(0, 10, 10) + np.random.uniform(-1.5, 1.5, 10)
plt.plot(x_data, y_data)
plt.show()
$ python3 example.py
Voila.