From: \Jonathan H. http://JonathansCorner.com\ <jon...@po...> - 2008-08-01 17:57:07
|
I found a reason for the behavior: The script was running as user apache, but trying to open /root/.matplotlib, and /root was mode 0700. It stopped crashing on import after I made /root mode 0711. This is somewhat surprising behavior to me; shouldn't it be defaulting to something besides expected access to ~root? On Fri, Aug 1, 2008 at 11:38 AM, Jonathan Hayward, http://JonathansCorner.com <jon...@po...> wrote: > Tried that and reran it; I'm getting substantially the same stacktrace: > > 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 > > It's /path/matplotlibrc and not /path/.matplotlibrc or anything like that? > > > On Fri, Aug 1, 2008 at 10:51 AM, Michael Droettboom <md...@st...>wrote: > >> Just throwing out a suggestion here: You could try putting a matplotlibrc >> file in the same directory as your Python script -- it will use that instead >> of the one in ~/.matplotlib. >> >> Cheers, >> Mike >> >> "Jonathan Hayward, http://JonathansCorner.com" wrote: >> >>> 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... <mailto: >>> 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 >>> ------------------------------------------------------------------------ >>> >>> ------------------------------------------------------------------------- >>> This SF.Net email is sponsored by the Moblin Your Move Developer's >>> challenge >>> Build the coolest Linux based applications with Moblin SDK & win great >>> prizes >>> Grand prize is a trip for two to an Open Source event anywhere in the >>> world >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>> ------------------------------------------------------------------------ >>> >>> _______________________________________________ >>> Matplotlib-users mailing list >>> Mat...@li... >>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >>> >>> >> >> -- >> Michael Droettboom >> Science Software Branch >> Operations and Engineering Division >> Space Telescope Science Institute >> Operated by AURA for NASA >> >> > > > -- > -- 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 > -- -- 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 |