How do I configure matplotlib to work on EC2?
Got it.
matplotlib uses a rendering backend which has to play nice with x11. But selecting the right backend manually [matplotlib.use('TkAgg')] would throw an exception. Turns out that matplotlib does not build correctly under ubuntu with pip, missing some dependencies--specifically the ones needed for x11-friendly backends (setting the default to 'Agg' in matplotlibrc). Fixed by:
pip uninstall matplotlib //unistall matplotlib
apt-get build-dep matplotlib //download and build needed dependencies
pip install -U matplotlib //force matplotlib rebuild
The above correctly sets the default backend to TkAgg (in matplotlibrc). Hope that helps someone!
Related videos on Youtube
Comments
-
denten over 1 year
We are trying to set up a virtual development / research cloud environment for our students. Students need to be able to log-in, launch python IDE, and plot some graphs for their homework.
We are running 64bit Ubuntu 12.10, with Python and IDLE ide installed. Students login with using ssh -X and launch IDLE, which spawns a GUI window.
Problem: running something like this in the ide
nltk.download()
spawns a new window. BUT when we try something like this:
book2.dispersion_plot("chair")
Nothing happens, where we would expect a new window to spawn and show the plot (thats what happens on the local machine). I suspect this has something to do with X11 but at this point I am way out of my depth of sys admin knowledge. Confirmed this both from a Mac (xQuartz) and PC (xming) client. Any help would be much appreciated.
-
wordsforthewise about 7 yearsThanks, but I think the last command is wrong. It's saying no such option: -U
-
denten about 7 yearsTry again. The incantation was missing an
install
command.