I am using Anaconda with Python 3.5.2, Matplotlib 2.0.2, PyQt5.6 on a windows 10 machine. When I import matplotlib.pyplot as plt I get the following error:
...
I had faced the same problem and here is how I fixed it.
Look into your matplotlib configuration file which is often located at path-to/site-packages/matplotlib/mpl-data/matplotlibrc or path-to/Anaconda3/envs/your_env_name/Lib/site-packages/matplotlib/mpl-data/matplotlibrc
See an example of matplotlibrc here https://github.com/daler/matplotlibrc/blob/master/rc/default
If you have pyqt5.x.x installed and have the statement 'backend : Qt5Agg' in matplotlibrc, then to use '%matplotlib qt', change '#backend.qt4 : PyQt4' to '#backend.qt4 : PyQt5'.
For an Anaconda environment, reactivate the environment.
Note if you update matplotlib in the future, your matplotlibrc will automatically be overwritten.