From: Daniel M. <dan...@ya...> - 2006-02-07 16:26:32
|
Please be kind....poor starving newbie. I've seen this question posted around but can't seem to find an answer: does anybody have experience creating an .exe for a matplotlib program using py2exe? My testMPL.py application is all set to go, but when I run py2exe with the suggested setup.py file, I get errors. (I'm using ActiveState Python 2.4.2 Build 10) Setup.py is as follows: from distutils.core import setup import glob import py2exe opts = { 'py2exe': { 'includes': 'matplotlib.numerix.random_array', 'excludes': ['_gtkagg', '_tkagg'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'] } } data = glob.glob("C:\\Python24\\Lib\\site-packages\\matplotlib\\*") data.append("C:\\Python24\\Lib\\site-packages\\matplotlib\\matplotlibrc") setup ( console = ["testWX.py"], data_files=[("matplotlibdata",data)]) Now, when I run this, setup.py ends with an error as follows: *** copy extensions *** *** copy dlls *** *** copy data files *** error: can't copy 'C:\Python24\Lib\site-packages\matplotlib\backends': doesn't e xist or not a regular file Is this error because glob can't load files recursively? I get confused because all of the other examples out there use a different file structure, loading matplotlib files like so... data_files = [(r'matplotlibdata', glob.glob(r'c:\python24\share\matplotlib\*')), (r'matplotlibdata', [r'c:\python24\share\matplotlib\.matplotlibrc'])], But my python build doesn't have a /share directory at all. Why the discrepency? Thanks for any help... - Daniel ===================================== Daniel McQuillen, Oakland, CA www.bluepattern.com |
From: John H. <jdh...@ac...> - 2006-02-08 02:52:42
|
>>>>> "Daniel" == Daniel McQuillen <dan...@ya...> writes: Daniel> Please be kind....poor starving newbie. I've seen this Daniel> question posted around but can't seem to find an answer: Daniel> does anybody have experience creating an .exe for a Daniel> matplotlib program using py2exe? Daniel> My testMPL.py application is all set to go, but when I run Daniel> py2exe with the suggested setup.py file, I get Daniel> errors. (I'm using ActiveState Python 2.4.2 Build 10) Daniel, just for our information: are you using the py2exe examples from the matplotlib FAQ page? I think these are probably a bit out of date as of the 0.86 release because of the way we recently reorganized the package data (fonts, thumbnails etc). Charlie, have you tested any of the new egg / package organization stuff with py2exe? JDH |
From: Charlie M. <cw...@gm...> - 2006-02-08 12:51:50
|
On 2/7/06, John Hunter <jdh...@ac...> wrote: > >>>>> "Daniel" =3D=3D Daniel McQuillen <dan...@ya...> writes: > > Daniel> Please be kind....poor starving newbie. I've seen this > Daniel> question posted around but can't seem to find an answer: > Daniel> does anybody have experience creating an .exe for a > Daniel> matplotlib program using py2exe? > > Daniel> My testMPL.py application is all set to go, but when I run > Daniel> py2exe with the suggested setup.py file, I get > Daniel> errors. (I'm using ActiveState Python 2.4.2 Build 10) > > Daniel, just for our information: are you using the py2exe examples > from the matplotlib FAQ page? I think these are probably a bit out of > date as of the 0.86 release because of the way we recently reorganized > the package data (fonts, thumbnails etc). > > Charlie, have you tested any of the new egg / package organization > stuff with py2exe? I just tried with an old project that I used py2exe with and it does look like we still need the py2exe specific check in get_data_path since py2exe zips the pure python code into a library.zip. I updated my setup.py file for that old project and I am pasting it below. In my specific case I was using numarray (numpy didn't exist), so now I have to exclude numpy or errors occur for some unknown reason. I just added the old py2exe check to get_data_path and everything worked fine. I will add this to cvs. Until the next release you can just uncomment the following lines in matplotlib/__init__.py#_get_data_path(): if sys.platform=3D=3D'win32' and sys.frozen: path =3D os.path.join(os.path.split(sys.path[0])[0], 'matplotlibdat= a') if os.path.isdir(path): return path else: # Try again assuming sys.path[0] is a dir not a exe path =3D os.path.join(sys.path[0], 'matplotlibdata') if os.path.isdir(path): return path Begin setup.py script ---------------------------------------------------------------------------= ----------- # For py2exe only """ Run with the following command (use py2exe 0.6.2 or higher) python.exe -OO setup.py py2exe -b 3 -c -p numarray,pytz -e numpy """ import os from distutils.core import setup import py2exe import glob import matplotlib mplfiles =3D glob.glob(os.sep.join([matplotlib.get_data_path(), '*'])) # Need to explicitly remove cocoa_agg nib folder or py2exe complains mplfiles.remove(os.sep.join([matplotlib.get_data_path(), 'Matplotlib.nib'])= ) setup( version =3D '0.9.1', windows =3D ['nlogui.py'], data_files =3D [('', ['nlo.gif', '../vtkrotate/NMA.pdb']), ('matplotlibdata', mplfiles)], options=3D{"py2exe":{"optimize":2}}, ) |
From: Charlie M. <cw...@gm...> - 2006-02-08 13:02:48
|
I just committed the changes to cvs and added a convenience function for py2exe called get_py2exe_datafiles. The script I pasted before now looks like this: Begin setup.py script ---------------------------------------------------------------------------= ----------- # For py2exe only """ Run with the following command (use py2exe 0.6.2 or higher) python.exe -OO setup.py py2exe -b 3 -c -p numarray,pytz -e numpy """ import os from distutils.core import setup import py2exe import glob import matplotlib setup( version =3D '0.9.1', windows =3D ['nlogui.py'], data_files =3D [('', ['nlo.gif', '../vtkrotate/NMA.pdb']), matplotlib.get_py2exe_datafiles()], options=3D{"py2exe":{"optimize":2}}, ) |
From: Daniel M. <da...@bl...> - 2006-02-12 03:50:35
|
Charlie Moad <cwmoad@...> writes: > > I just committed the changes to cvs and added a convenience function > for py2exe called get_py2exe_datafiles. Charlie and John, John, in answer to your question, yes, I was using the py2exe examples from the FAQ page. Charlie, I'll try out the convenience function you created and report back with my findings. Hopefully this will be of use to other users who have the same file structure as I do. With Thanks, Daniel Oakland, CA www.bluepattern.com |
From: Daniel M. <dan...@ya...> - 2006-03-17 21:10:35
|
Daniel McQuillen <daniel@...> writes: > Charlie Moad <cwmoad <at> ...> writes: > > > > > I just committed the changes to cvs and added a convenience function > > for py2exe called get_py2exe_datafiles. > Charlie, Thanks for your help. I tried running your script and got an error originating from the function you wrote within __init__.py. I tried the function by itself within PyShell and got the same error...here's the error I received: File "setup.py", line 23, in ? data_files = [('', ['nlo.gif', '../vtkrotate/NMA.pdb']), File "C:\Python24\Lib\site-packages\matplotlib\__init__.py", line 367, in get_ py2exe_datafiles mplfiles = glob.glob(os.sep.join([matplotlib.get_data_path(), '*'])) NameError: global name 'matplotlib' is not defined This seems to be the code that you added to the __init__.py file: def get_py2exe_datafiles(): import glob mplfiles = glob.glob(os.sep.join([matplotlib.get_data_path(), '*'])) # Need to explicitly remove cocoa_agg files or py2exe complains mplfiles.remove(os.sep.join([matplotlib.get_data_path(), 'Matplotlib.nib'])) return ('matplotlibdata', mplfiles) I removed the matplotlib references and the code then worked: def get_py2exe_datafiles(): import glob mplfiles = glob.glob(os.sep.join([get_data_path(), '*'])) # Need to explicitly remove cocoa_agg files or py2exe complains mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib'])) return ('matplotlibdata', mplfiles) I can now create an .exe. I'll post soon as to how well the .exe actually works. Thanks for your help. Daniel Oakland, CA |
From: Daniel M. <dan...@ya...> - 2006-03-17 21:39:20
|
Daniel McQuillen <danmcquillen@...> writes: A follow up note from my posting today: Although the .exe was successfully created by py2exe, when I try to run it,I only get an "Errors Occurred" dialog window with the following written to the log: Traceback (most recent call last): File "VizTool.py", line 2, in ? File "VizTool\Controllers.pyo", line 4, in ? File "VizTool\GraphPanels.pyo", line 1, in ? File "wxmpl.pyo", line 32, in ? File "matplotlib\numerix\__init__.pyo", line 145, in ? ImportError: No module named random_array Here's my setup script. Note that I've included the line suggested by the py2exe wiki (http://starship.python.net/crew/theller/moin.cgi/MatPlotLib) to try to remedy this missing random_array module, but am still getting that error. import os from distutils.core import setup import py2exe import glob import matplotlib opts = { 'py2exe': { 'includes': 'matplotlib.numerix.random_array', 'excludes': ['_gtkagg', '_tkagg'], 'dll_excludes': ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll'] } } setup( version = '0.0.1', windows = ['VizTool.py'], data_files = [('data', ['data/CH2.csv']), ('conf',['conf/GraphStyles.ini']), ('',['matplotlibrc']), matplotlib.get_py2exe_datafiles()], options={"py2exe":{"optimize":2}}, ) This is the setup.py command at the DOST prompt: C:>python.exe -OO setup.py py2exe -b 3 -c -p numarray,pytz -e numpy Thanks for any help anybody can provide! Regards, Daniel McQuillen Oakland, CA |
From: Charlie M. <cw...@gm...> - 2006-03-18 01:31:00
|
Are you using numarray as your numerix? If so, is it specified in matplotlibrc of the exe bundle? On 3/17/06, Daniel McQuillen <dan...@ya...> wrote: > Daniel McQuillen <danmcquillen@...> writes: > > A follow up note from my posting today: > > Although the .exe was successfully created by py2exe, > when I try to run it,I only get an "Errors Occurred" > dialog window with the following written to the > log: > > Traceback (most recent call last): > File "VizTool.py", line 2, in ? > File "VizTool\Controllers.pyo", line 4, in ? > File "VizTool\GraphPanels.pyo", line 1, in ? > File "wxmpl.pyo", line 32, in ? > File "matplotlib\numerix\__init__.pyo", line 145, in ? > ImportError: No module named random_array > > Here's my setup script. Note that I've included the > line suggested by the py2exe wiki > (http://starship.python.net/crew/theller/moin.cgi/MatPlotLib) > to try to remedy this missing random_array module, > but am still getting that error. > > > import os > from distutils.core import setup > import py2exe > import glob > > import matplotlib > > opts =3D { > 'py2exe': { 'includes': 'matplotlib.numerix.random_array', > 'excludes': ['_gtkagg', '_tkagg'], > 'dll_excludes': ['libgdk-win32-2.0-0.dll', > 'libgobject-2.0-0.dll'] > } > } > > setup( version =3D '0.0.1', > windows =3D ['VizTool.py'], > data_files =3D [('data', ['data/CH2.csv']), > ('conf',['conf/GraphStyles.ini']), > ('',['matplotlibrc']), > matplotlib.get_py2exe_datafiles()], > options=3D{"py2exe":{"optimize":2}}, > ) > > > > This is the setup.py command at the DOST prompt: > > C:>python.exe -OO setup.py py2exe -b 3 -c -p numarray,pytz -e numpy > > Thanks for any help anybody can provide! > > Regards, > > Daniel McQuillen > Oakland, CA > > > > > > > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Daniel M. <dan...@ya...> - 2006-03-20 22:02:53
|
Charlie Moad <cwmoad@...> writes: > > Are you using numarray as your numerix? If so, is it specified in > matplotlibrc of the exe bundle? Charlie, Yes. I'm using numarray for numerix. I've specified this in a local matplotlibrc file that configures my application, as well as the default matplotlibrc file in the C:\Python24\Lib\site-packages\matplotlib\mpl-data directory. My .exe is called VizTool.exe. The output from VizTool.exe.log is : Traceback (most recent call last): File "VizTool.py", line 2, in ? File "VizTool\Controllers.pyo", line 4, in ? File "VizTool\GraphPanels.pyo", line 1, in ? File "wxmpl.pyo", line 32, in ? File "matplotlib\numerix\__init__.pyo", line 145, in ? ImportError: No module named random_array Any suggestions? As always, thanks for the help. Regards, Daniel McQuillen Oakland, CA |
From: Charlie M. <cw...@gm...> - 2006-03-18 01:29:33
|
I fixed the matplotlib references. I must have been importing it in my script. Thanks for the info. - Charlie On 3/17/06, Daniel McQuillen <dan...@ya...> wrote: > Daniel McQuillen <daniel@...> writes: > > > > Charlie Moad <cwmoad <at> ...> writes: > > > > > > > > I just committed the changes to cvs and added a convenience function > > > for py2exe called get_py2exe_datafiles. > > > > Charlie, > > Thanks for your help. I tried running your script and got an error origin= ating > from the function you wrote within __init__.py. I tried the function by i= tself > within PyShell and got the same error...here's the error I received: > > File "setup.py", line 23, in ? > data_files =3D [('', ['nlo.gif', '../vtkrotate/NMA.pdb']), > File "C:\Python24\Lib\site-packages\matplotlib\__init__.py", line 367, = in get_ > py2exe_datafiles > mplfiles =3D glob.glob(os.sep.join([matplotlib.get_data_path(), '*'])= ) > NameError: global name 'matplotlib' is not defined > > > This seems to be the code that you added to the __init__.py file: > > def get_py2exe_datafiles(): > import glob > > mplfiles =3D glob.glob(os.sep.join([matplotlib.get_data_path(), '*'= ])) > # Need to explicitly remove cocoa_agg files or py2exe complains > mplfiles.remove(os.sep.join([matplotlib.get_data_path(), 'Matplotli= b.nib'])) > > return ('matplotlibdata', mplfiles) > > I removed the matplotlib references and the code then worked: > > > def get_py2exe_datafiles(): > import glob > > mplfiles =3D glob.glob(os.sep.join([get_data_path(), '*'])) > # Need to explicitly remove cocoa_agg files or py2exe complains > mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib'])) > > return ('matplotlibdata', mplfiles) > > > I can now create an .exe. I'll post soon as to how well the .exe actually= works. > > Thanks for your help. > > Daniel > Oakland, CA > > > > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting langua= ge > that extends applications into web and mobile media. Attend the live webc= ast > and join the prime developer group breaking into this new coding territor= y! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat= =3D121642 > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |