I have tried repeatedly to install the QGIS Semi-automatic classification plugin via both (1) Plugins > Install & Manage Plugins and (2) manually based on other comments I found here, but I can't get it to work. I continue to get the error:

The plugin is broken. Python said:
No module named matplotlib.backends.backend_qt4agg

I have checked and have installed matplotlib, GDAL, scipy, numpy via macports (QGIS was installed via macports as well, but I have uninstalled, reinstalled, and rebooted a couple of times at this point).

I am not sure how else to proceed.

1 Answer 1


Matplotlib has many backends

In my Mac OS X matplotlib (1.4.2) installation, using the pure Python script in List of all available matplotlib backends the result is:

 print backends
 ['agg', 'cairo', 'cocoaagg', 'gdk', 'gtk', 'gtk3', 'gtk3agg', 'gtk3cairo', 'gtkagg', 'gtkcairo', 'macosx', 'mixed', 'nbagg', 'pdf', 'pgf', 'ps', 'qt4', 'qt4agg', 'qt5', 'qt5agg', 'svg', 'template', 'tkagg', 'webagg', 'webagg_core', 'wx', 'wxagg']

As you can see, there is a 'qt4agg' backend

As I use the default Apple Python, the backends files are in /Library/Python/2.7/site-packages/matplotlib-1.4.2/matplotlib/backends

enter image description here

So your matplotlib is not correctly installed or you PYTHONPATH is not correct. Look at Macports Ticket: py27-matplotlib say py27-pyqt4 not installed when using qt-backend

But why use MacPorts ? There are other solutions available, more reliable, KyngChaos or Homebrew, look at QGIS python location problem

  • This was incredibly helpful thank you! It did appear that there was a simple inconsistency between where Mac Ports installed python and what backends were identified. I ensured that python27 was the active python and then copied: cp /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mpl-data/matplotlibrc ~/.matplotlib/ and uncommented the line: backend.qt4 : PyQt4 in the matplotlib file.
    – sbs
    Feb 2, 2015 at 17:48
  • I default to using MacPorts because I have other dependencies already utilizing installation paths from MacPorts. In my experience, when you install Homebrew and start using it for additional installs, many conflicts can arise.
    – sbs
    Feb 2, 2015 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.