MatPlotLib and Py2Exe, problems with get_data_path ?

hello,

Can someone tell me how to include MatPlotLib in a Py2Exe package.
I seem to have trouble with the matplot's get_data_path

After running Py2exe, packing everything with inno setup, installing the resulting package and the run the program,
I get the following error message.

Traceback (most recent call last):
  File "PyLab_Works.py", line 42, in ?
  File "PyLab_Works_appform.pyc", line 13, in ?
  File "control_matplot.pyc", line 42, in ?
  File "pylab.pyc", line 1, in ?
  File "matplotlib\__init__.pyc", line 639, in ?
  File "matplotlib\__init__.pyc", line 562, in rc_params
  File "matplotlib\__init__.pyc", line 517, in matplotlib_fname
  File "matplotlib\__init__.pyc", line 207, in wrapper
  File "matplotlib\__init__.pyc", line 447, in _get_data_path_cached
  File "matplotlib\__init__.pyc", line 443, in _get_data_path
RuntimeError: Could not find the matplotlib data files

From another post I saw a py2exe script,
where the matplotlib data files were copied to the subdirectory "matplotlibdata" of the installed directory.
As this can be done far more easy in Inno Setup, I used:

I've copied the matplotlib datafiles with an inno command:
; MatPlotLib
Source: "P:\Python\Lib\site-packages\matplotlib\mpl-data\*.*"; \
  DestDir: "{app}\{#prog_path}\matplotlibdata\"; \
  Flags: ignoreversion recursesubdirs; \
  Components: Program;

But apparently MatPlotLib can't find it ??

Suggestions would de very welcome (especially because a lot ofpeople seems to have trouble with this).

thanks,
Stef Mientki

Hi Stef,

Stef Mientki wrote:

hello,

Can someone tell me how to include MatPlotLib in a Py2Exe package.
I seem to have trouble with the matplot's get_data_path

After running Py2exe, packing everything with inno setup, installing the resulting package and the run the program,
I get the following error message.

Traceback (most recent call last):
File "PyLab_Works.py", line 42, in ?
File "PyLab_Works_appform.pyc", line 13, in ?
File "control_matplot.pyc", line 42, in ?
File "pylab.pyc", line 1, in ?
File "matplotlib\__init__.pyc", line 639, in ?
File "matplotlib\__init__.pyc", line 562, in rc_params
File "matplotlib\__init__.pyc", line 517, in matplotlib_fname
File "matplotlib\__init__.pyc", line 207, in wrapper
File "matplotlib\__init__.pyc", line 447, in _get_data_path_cached
File "matplotlib\__init__.pyc", line 443, in _get_data_path
RuntimeError: Could not find the matplotlib data files

From another post I saw a py2exe script,
where the matplotlib data files were copied to the subdirectory "matplotlibdata" of the installed directory.
As this can be done far more easy in Inno Setup, I used:

I've copied the matplotlib datafiles with an inno command:
; MatPlotLib
Source: "P:\Python\Lib\site-packages\matplotlib\mpl-data\*.*"; \
DestDir: "{app}\{#prog_path}\matplotlibdata\"; \
Flags: ignoreversion recursesubdirs; \
Components: Program;

But apparently MatPlotLib can't find it ??

What version of matplotlib are you using?

In late November I posted a setup.py sample which works for me with matplotlib 0.90, but I use the py2exe data_files option to copy the files, does that setup.py work for you?

Werner

Hi Stef,

Stef Mientki wrote:

....

In late November I posted a setup.py sample which works for me with matplotlib 0.90, but I use the py2exe data_files option to copy the files, does that setup.py work for you?

was in this discussionlist ?
I couldn't find your setup.py,
looked in november, looked all your posts, searched for matplotlib, searched for py2exe, but ...

Oops, didn't notice that this came in from wxPython list it got filed under matplotlib.

I had posted that on the matplotlib list, I'll attach anyhow with the corresponding matplotlib example script.

Werner

setup.py (4.41 KB)

embedding_in_wx.py (3.41 KB)

thanks Werner,

Werner F. Bruhin wrote:

Hi Stef,

Stef Mientki wrote:

....

In late November I posted a setup.py sample which works for me with matplotlib 0.90, but I use the py2exe data_files option to copy the files, does that setup.py work for you?

was in this discussionlist ?
I couldn't find your setup.py,
looked in november, looked all your posts, searched for matplotlib, searched for py2exe, but ...

Oops, didn't notice that this came in from wxPython list it got filed under matplotlib.

can happen,
but if you use Thunderbird, it's easy to create filters, so every list comes in a different folder.

I had posted that on the matplotlib list, I'll attach anyhow with the corresponding matplotlib example script.

With your script and a little trial and error, I finally solved the datapath problem:
if MatPlotLib_Wanted :
  import matplotlib

  includes.append ( 'matplotlib.numerix.random_array' )

  packages.append ( 'matplotlib' )
  packages.append ( 'pytz' )

  data_files.append ( ( r'mpl-data', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\*.*' )))
  data_files.append ( ( r'mpl-data', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\matplotlibrc' )))
  data_files.append ( ( r'mpl-data\\images', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\images\\*.*' )))
  data_files.append ( ( r'mpl-data\\fonts\\afm', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\fonts\\afm\\*.*' )))
  data_files.append ( ( r'mpl-data\\fonts\\pdfcorefonts', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\fonts\\pdfcorefonts\\*.*' )))
  data_files.append ( ( r'mpl-data\\fonts\\ttf', glob.glob (
    r'P:\\Python\\Lib\\site-packages\\matplotlib\\mpl-data\\fonts\\ttf\\*.*' )))

btw does anyone knows where the 'r' in front of the paths stands for ?

But now I bumped into other problems with backends, (I'll start a new thread),
so for the moment I removed MatPlotLib,
and I can make a working distribution.

cheers,
Stef

···

Werner

Hi Stef,

Stef Mientki wrote:

....

btw does anyone knows where the 'r' in front of the paths stands for ?

http://docs.python.org/ref/strings.html

Werner

Werner F. Bruhin wrote:

Hi Stef,

Stef Mientki wrote:

....

btw does anyone knows where the 'r' in front of the paths stands for ?

http://docs.python.org/ref/strings.html

thanks Werner,
cheers,
Stef

···

Werner

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org