From: Rodney H. <RH...@co...> - 2008-08-03 03:41:10
|
Jonathan, If you did not get a response by now, you can try the following. import os# set HOME environment variable to a directory the httpd server can write to os.environ[ 'HOME' ] = 'c:/www/app/tmp/' Good luck. -Rodney _____ From: mat...@li... [mailto:mat...@li...] On Behalf Of "Jonathan Hayward, http://JonathansCorner.com" Sent: Friday, August 01, 2008 11:26 AM To: Matplotlib Subject: [Matplotlib-users] Crash on import with CGI wrapped by PHP--unhappywith .matplotlib directory? I have a PHP script which authenticates a user and I am trying to get the PHP script to wrap a Python script using matplotlib. As it is, the script mostly works when invoked from the command line or as its own CGI script. When I call it from a PHP script, it doesn't produce output, and testing found that when I call a Python script from a PHP script, output works before but not after "import matplotlib": if the PHP script calls a script of: #!/usr/bin/python print "Before import matplotlib." import matplotlib; print "After import matplotlib." the first print statement succeeds but the second one fails; the server log shows a crash of: Before import matplotlib.Traceback (most recent call last): File "/home/jhayward/bintmp/test.py", line 5, in <module> import matplotlib; File "/usr/lib64/python2.5/site-packages/matplotlib/__init__.py", line 639, in <module> rcParams = rc_params() File "/usr/lib64/python2.5/site-packages/matplotlib/__init__.py", line 562, in rc_params fname = matplotlib_fname() File "/usr/lib64/python2.5/site-packages/matplotlib/__init__.py", line 513, in matplotlib_fname fname = os.path.join(get_configdir(), 'matplotlibrc') File "/usr/lib64/python2.5/site-packages/matplotlib/__init__.py", line 207, in wrapper ret = func(*args, **kwargs) File "/usr/lib64/python2.5/site-packages/matplotlib/__init__.py", line 403, in _get_configdir raise RuntimeError("Failed to create %s/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data"%h) RuntimeError: Failed to create /root/.matplotlib; consider setting MPLCONFIGDIR to a writable directory for matplotlib configuration data I think this error is somewhat misleading; it persisted after I ran a "chmod -R 1777 /root/.matplotlib". What is the proper way to adjust things so matplotlib will be happy with its .matplotlib directory? -- -- Jonathan Hayward, chr...@gm... ** To see an award-winning website with stories, essays, artwork, ** games, and a four-dimensional maze, why not visit my home page? ** All of this is waiting for you at http://JonathansCorner.com ++ Would you like to curl up with one of my hardcover books? ++ You can now get my books from http://CJSHayward.com |