It's not matplotlib but mercurial that prints into stdout. > File"/usr/lib/pymodules/python2.6/mercurial/ui.py",line232,inwrite > sys.stdout.write(str(a)) > IOError:sys.stdout access restricted by mod_wsgi
About matplotlib, in case there's still problem, can you try to enter plot.py's contents one by one into a python prompt and see whether that works. May be some installation problem of matplotlib. I installed matplotlib for testing your problem $> sudo apt-get install python-matplotlib $> ipython >>>import matplotlib >>>matplotlib.__version__ '0.99.3' >>>import matplotlib >>>import matplotlib.cbook >>>from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas >>>from matplotlib.backend_bases import RendererBase And I got no errors about imports, or attribut error as you got > File"/usr/lib/pymodules/python2.6/matplotlib/backend_bases.py",line29,in<module> > importmatplotlib.cbook as cbook > AttributeError:'module'object has no attribute'cbook' In case you got this same error while trying this on python prompt, try reinstalling the library.

