# py2exe problems for a tkinter/matpotlib project - works for me, but not for others

Hi Werner

2010/3/15 Werner F. Bruhin <werner.bruhin@…185…>

Hi
Kim,

Changing the line 560 in mathtext.py from:

       font = FT2Font(basename)


to:

       font = FT2Font(str(basename))


Fixed it for me, I don’t know what FT2Font does and why this matters -
hopefully someone else can expand on this.

This worked here as well - sort of, at least.

It was just a guess, as I noticed that the other call to FT2Font is
using str too.

It does not crash anymore, but the LaTeX $\alpha-\beta$ in the
title is not rendered correctly in the title of the graph for the users

Yeap, I see this now too.

I guess it must be due to some fonts not being available in the
dist, which are available to me and others. I do not know if there is a
way to patch up setup.py such that the needed fonts are included in the
dist?

It should be there, i.e. mpl-data in the lib/site-packages/matplotlib
folder has the same number of files and folders as the one created by
setup.py in dist.

But it obviously doesn’t find it or some other setting to handle the
LaTex stuff is not there.

Put this at the top of alphabeta.py, i.e. just after import matplotlib

matplotlib.verbose.level = u’debug’

and change setup.py to generate a console app. If I run this on my dev
machine the output shows that fonts are found, but if I run it on the
py2exe’d version lots of STIX fonts are not found. Even so these fonts
are in mpl-data/fonts/ttf of the py2exe dist folder.

So, I think/guess that the font searching is not done correctly, as
running with verbose “debug” it shows that it finds the mpl-data folder
in the dist folder or wherever you copy dist too.

Hopefully someone who knows how the font searching is done can help
out/point to the culprit.

Attached your setup.py a bit simplified as you are
using matplotlib 0.99.

Thank you. I am using your setup.py now. It was very kind of you
to send that.

You are welcome

Werner

···

On 15/03/2010 14:37, Kim Hansen wrote:

Werner F. Bruhin wrote:

It should be there, i.e. mpl-data in the lib/site-packages/matplotlib
folder has the same number of files and folders as the one created by
setup.py in dist.

But it obviously doesn't find it or some other setting to handle the
LaTex stuff is not there.

Put this at the top of alphabeta.py, i.e. just after import matplotlib

matplotlib.verbose.level = u'debug'

and change setup.py to generate a console app. If I run this on my dev
machine the output shows that fonts are found, but if I run it on the
py2exe'd version lots of STIX fonts are not found. Even so these fonts
are in mpl-data/fonts/ttf of the py2exe dist folder.

So, I think/guess that the font searching is not done correctly, as
running with verbose "debug" it shows that it finds the mpl-data folder
in the dist folder or wherever you copy dist too.

Hopefully someone who knows how the font searching is done can help
out/point to the culprit.

Hi all!
Any fix for this problem?
I have the same issue!
I'm using:
OS: windows xp sp3
Python: 2.6.6
numpy: 1.5.1
scipy: 0.8.0
matplotlib: 1.0.0
Tkinter
The .py script compiles well to exe program, but the matplotlib fonts
searching is done in D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts
(I have insatalled python in D:\python26) instead of dist\mpl-data\fonts
Matplotlib images in \dist\mpl-data\images are loaded correctly.
In dist\mpl-data\fonts I have same files and folder that are in
D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts
So if the folder fonts is in
D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts the exe program runs
correctly, but if I delete that folder the program doesn't plot tha data and
the log shows an error because it doesn't find the Vera font.
I attach the setup.py http://old.nabble.com/file/p30562579/setup.py setup.py

Any help is appreciated!

···

View this message in context: http://old.nabble.com/py2exe-problems-for-a-tkinter-matpotlib-project---works-for-me%2C-but- not-for-others-tp27902210p30562579.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

Browsing the web I think I find the solution
Hope this helps other users:
The only thing I did is to delete the file:
D:\Documents and Settings\Daniele\.matplotlib\fontList.cache
NB: My windows user is Daniele
Then start the exe and all is plotted correctly!

NB2: everytime I change the name of the "dist" directory I also have to
re-delete the fontList.cache file!

Daniele

ghost82 wrote:

···

Werner F. Bruhin wrote:

It should be there, i.e. mpl-data in the lib/site-packages/matplotlib
folder has the same number of files and folders as the one created by
setup.py in dist.

But it obviously doesn't find it or some other setting to handle the
LaTex stuff is not there.

Put this at the top of alphabeta.py, i.e. just after import matplotlib

matplotlib.verbose.level = u'debug'

and change setup.py to generate a console app. If I run this on my dev
machine the output shows that fonts are found, but if I run it on the
py2exe'd version lots of STIX fonts are not found. Even so these fonts
are in mpl-data/fonts/ttf of the py2exe dist folder.

So, I think/guess that the font searching is not done correctly, as
running with verbose "debug" it shows that it finds the mpl-data folder
in the dist folder or wherever you copy dist too.

Hopefully someone who knows how the font searching is done can help
out/point to the culprit.

Hi all!
Any fix for this problem?
I have the same issue!
I'm using:
OS: windows xp sp3
Python: 2.6.6
numpy: 1.5.1
scipy: 0.8.0
matplotlib: 1.0.0
Tkinter
The .py script compiles well to exe program, but the matplotlib fonts
searching is done in
D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts (I have insatalled
python in D:\python26) instead of dist\mpl-data\fonts
Matplotlib images in \dist\mpl-data\images are loaded correctly.
In dist\mpl-data\fonts I have same files and folder that are in
D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts
So if the folder fonts is in
D:\Python26\Lib\site-packages\matplotlib\mpl-data\fonts the exe program
runs correctly, but if I delete that folder the program doesn't plot tha
data and the log shows an error because it doesn't find the Vera font.
I attach the setup.py http://old.nabble.com/file/p30562579/setup.py
setup.py

Any help is appreciated!

View this message in context: http://old.nabble.com/py2exe-problems-for-a-tkinter-matpotlib-project---works-for-me%2C-but- not-for-others-tp27902210p30562913.html
Sent from the matplotlib - users mailing list archive at Nabble.com.