From: Jae-Joon L. <lee...@gm...> - 2009-02-23 02:40:31
|
I think the error is raised when you try to import matplotlib (not when you try to save your figure) matplotlib needs its config directory writable. It first try MPLCONFIGDIR env. variable, then try $HOME/.matplotlib. Here, the $HOME is the home directory of the user executing the script. I think it would be better to set MPLCONFIGDIR env. variable (it should be env. variable, not rcparams) instead of HOME. The directory referred by MPLCONFIGDIR must exist. Unfortunately, I'm not an expert on apache and I can't tell you which is the best way to set the env. variable. -JJ On Fri, Feb 20, 2009 at 4:50 PM, bpklmd <rp...@re...> wrote: > > I have searched the web for a solution to the following problem and nothing > works. > > > I call matplotlib code from a python script (2.5) running on Apache2.2 and > mod_python. When I get to the point where I the code is to save a figure in > the website dir I get the following error. > > File "/usr/lib/python2.5/site-packages/matplotlib/__init__.py", line 324, in > _get_configdir > raise RuntimeError("'%s' is not a writable dir; you must set environment > variable HOME to be a writable dir "%h) > > RuntimeError: '/root' is not a writable dir; you must set environment > variable HOME to be a writable dir > > The code that creates the fig is a follows: > > import matplotlib > from matplotlib import pylab as plt > import numpy as np > > matplotlib.use('AGG') # use a nongui backend > matplotlib.rdParams['MPLCONFIGDIR']='/var/www/modtest/' > ... > plot code here > ... > > plt.savefig('/var/www/modtest/plot_data/' + plotfile[0]) # use 1st > generated random file name > > First can anyone tell me what "HOME" variable the error message is referring > to? > I have changed the $HOME env variable under linux Ubuntu Gutsy > I have added a $HOME variable to httpd.conf, however I am not an > experienced Apache user > I can get the code to work from the interactive.py shell > > > > rlp > -- > View this message in context: http://www.nabble.com/Problems-with-saving-figure-from-within-mod_python-script-tp22129192p22129192.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA > -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise > -Strategies to boost innovation and cut costs with open source participation > -Receive a $600 discount off the registration fee with the source code: SFAD > http://p.sf.net/sfu/XcvMzF8H > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |