MatPlotLib + Py2exe, backend problems ...

I *finally* got this to work!!!

Thanks to Werner's message, I found the culpit: the
matplotlibrc file copied to the dist directory
contains the TkAgg backend. All I had to do is to
change *that* file to say:

backend : WXAgg

Note that it's not the matplotlibrc in the installed
copy - but the one in the resulting dist directory.

In addition, I have to do a:

   set MATPLOTLIBDATA=.\mpl-data

before I start the exe file. I don't know why this is
necessary because the code for _get_data_path appears
to look at that directory by default but if I don't
set this, it can't find the data files.

In any event, it works now - after bumping head for 2
weeks!

Thanks everybody.

From: Werner F. Bruhin

[mailto:werner.bruhin@…185…]

Sent: Wednesday, February 20, 2008 1:45 AM
To: kc106_2005-matplotlib@...9...
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] MatPlotLib + Py2exe,

backend problems ...

Hi,

kc106_2005-matplotlib@...9... wrote:
> So, do I understand this correctly:
>
> In order to get rid of the Tkinter problem when
> building a matplotlib application using py2exe, I

need

> 0.91.2 ver of matplotlib and use the setup.cfg

file to

> select the backend I want (wxpython in my case).

Then

> run py2exe to build the ap. Correct?
>
I haven't tried it with 0.91.x but with 0.90 I used

a

matplotlib exe installer for Windows and I can

create a

distribution of my application with py2exe which

does NOT

contain tkinter.

> But then, as I posted earlier, this create a new
> problem for me in that py2exe says it can't find

wxmsw26uh_vc.dll -

> even though the file exists.
>
That dll should no longer be needed by matplotlib.

Obviously

if you use a wxPython build you will get the it,

i.e. I am on

2.8 so I have a bunch of "wxmsw26uh???.dll" files

in my dist folder.

> What I need is a version of 0.91.2 ver of

matplotlib

> that works with Python 2.3 to see if that works,

or I

> guess I would include Tkinter with my exe?
>
There was another message from Stef which might be

the

explanation, the default matplotlibrc file is

defining TKAgg

as the default backend, so change it to the

following:

···

-----Original Message-----

backend : WXAgg
numerix : numpy # numpy, Numeric or numarray

Werner

--
John Henry

Hi,

kc106_2005-matplotlib@...9... wrote:

I *finally* got this to work!!!

Thanks to Werner's message, I found the culpit: the
matplotlibrc file copied to the dist directory
contains the TkAgg backend. All I had to do is to
change *that* file to say:

backend : WXAgg

Note that it's not the matplotlibrc in the installed
copy - but the one in the resulting dist directory.

In addition, I have to do a:

   set MATPLOTLIBDATA=.\mpl-data
  

You shouldn't need to do this. Note in matplotlib.__init__.py, it looks at a different folder if it is frozen by py2exe or py2app or ...:
    # py2exe zips pure python, so still need special check
    if getattr(sys,'frozen',None):
        path = os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdata')

So, if you use the sample setup.py I posted a while ago here and on the wxPython list it will create the matplotlibdata folder in your distribution (basically a copy of your mpl-data folder) folder.

before I start the exe file. I don't know why this is
necessary because the code for _get_data_path appears
to look at that directory by default but if I don't
set this, it can't find the data files.

In any event, it works now - after bumping head for 2
weeks!
  

Hope the wall wasn't to hard, I always try this or the wxPython list after a day or two :wink: .

See you
Werner