On Sat, Mar 28, 2009 at 11:45 PM, Eric Firing <efir...@hawaii.edu> wrote:

> Karen Tracey wrote:
>
>  Hmm, the Ubuntu packaging for matplotlib seems to put a copy of
>> matplotlibrc only in /etc, where, I gather, it will not ever be used by
>> matplotlib?  I guess one is supposed to copy it to one's home directory and
>> do per-user customization there.  For my case, where the code is running
>> under Apache, I'd guess no matplotlibrc is being found so all defaults are
>> being used.
>>
>
> Karen,
>
> That seems a little odd; matplotlib doesn't look in /etc by default.
> Although I run ubuntu, I have never used the ubuntu package, so I have not
> run into this.
>
> The default matplotlibrc has been stripped down to a bare minimum:
> everything but the default backend selection is commented out.
>
> You may have already discovered this, but in case you haven't, you can find
> out where the active matplotlibrc is being found by using
> matplotlib_fname():
>
> In [1]:import matplotlib
>
> In [2]:matplotlib.matplotlib_fname()
>
> Out[2]:'/usr/local/lib/python2.5/site-packages/matplotlib/mpl-data/matplotlibrc'
>

Thanks, I hadn't found that.  It seems the Ubuntu packaging has changed
things a bit:

k...@lbox:~$ python
Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> matplotlib.__version__
'0.98.3'
>>> matplotlib.matplotlib_fname()
'/etc/matplotlibrc'
>>> matplotlib.get_data_path()
'/usr/share/matplotlib/mpl-data'
>>>

Looking at the source code, I see in
/usr/lib/python2.5/site-packages/matplotlib/__init__.py (which is actually a
link to /usr/share/pyshared/matplotlib/__init__.py which I gather is a way
of having packages that run under multiple Python versions only have one
copy of the files installed), in matplotlib_fname, the very end is:

    path =  '/etc' # guaranteed to exist or raise
    fname = os.path.join(path, 'matplotlibrc')
    if not os.path.exists(fname):
        warnings.warn('Could not find matplotlibrc; using defaults')
    return fname

That is, it looks like they have hardcoded '/etc' where the
lib/matplotlib/__init__.py file in SVN has a call to get_data_path().  Don't
know why, but apparently if you run the Ubuntu repository version it's
/etc/matplotlibrc that gets used (assuming nothing is found earlier in the
search order).  They like all config-type files to be under /etc maybe?


>
Thank you for the test script.  I have added it to the "unit" subdirectory
> of matplotlib, after adding a short docstring.  JDH may want to modify or
> move it.
>
>
You're welcome.  Hope it's useful.  I am glad the fix was relatively
simple.

Karen
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to