On 6/2/06, Russell E. Owen <[EMAIL PROTECTED]> wrote: > I'm using matplotlib in an application I distribute. For Windows and Mac > users I distribute a frozen application which includes python, > matplotlib, etc. and I'm wondering how best to include the matplotlib > data files. > > matplotlib searches for its data files in __init__._get_data_path. It > seems to search shared locations first, then locations that would be > relevant to a frozen application. Is that safe? I worry that if a user > of my app has their own version of matplotlib (possibly a very different > version than I've included) then the data files might be different. > > If this really is an issue, then what to do?
The only way you could have conflicting data sources is if MATPLOTLIBDATA is defined in your environment. If someone is capable of setting that I am inclined to think they might know what to do in case of an error. If that env var is not set, then mpl looks inside the its module. Different installs will not see the others. We finally have a special case for frozen installations. It has primarily been made for py2exe, in which you should have a folder called 'matplotlibdata' in your app's bundle. > For Mac I can put the data files deep in the app in > Contents/Frameworks/Python.Framework/2.4/share/matplotlib, which is the > second location looked at (after environment variable MATPLOTLIBDATA). The second location should be: ....Frameworks/Python.Framework/2.4/lib/python2.4/matplotlib/mpl-data Are you using an old version of matplotlib? > For Windows, there doesn't seem any way out. The Windows frozen test is > dead last. You can remove the MATPLOTLIBDATA env var from os.environ in your code. > > --- > > Also, should I worry about the user's local matplotlibrc file (which > again might be for the wrong version or might never have been created or > configured at all -- the main problem I've hit so far is that the > auto-created default of this file is always wrong about the back > end--picking gtkagg even though I don't even build gtk support). > > Again, that looks difficult or impossible because the search order is > for the usual user locations first, then look in the data directory. In my experience with distributing apps with matplotlib, I have known in advanced the packages I want to use. For example, if I know I am going to bundle Tkinter and numpy, then I make sure I have the following before using any matplotlib commands. import matplotlib matplotlib.use('TkAgg') matplotlib.rcParams['numerix'] = 'numpy' This makes sure your app uses you desired backend modules no matter what the global config says. Good luck, Charlie _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users