pyinstall and matplotlib

John Henry john106henry at hotmail.com
Mon Feb 18 23:04:25 EST 2008


On Feb 18, 7:34 pm, John Henry <john106he... at hotmail.com> wrote:
> On Feb 17, 11:50 am, Stef Mientki <stef.mien... at gmail.com> wrote:
>
>
>
> > hi John,
>
> > John Henry wrote:
> > > Anybody willing to help?
>
> > I struggled the past few days with the same problem,
> > and with the help of Werner Bruhin (wxPython list) I found a solution.
> > I had 2 problems:
> >   - not finding mpl datapath
> >   - matplotlib insisted on installing backends that were distorted on my
> > system
>
> > The first problem was solved with the following script:
> > it has some special parts
> > - remove the distro and build directories before running setup
> > - a special matplot part, ensuring mpl-data is copied and installed
> > - a lot of excludes for matplotlib ( which doesn't seem to work :-( )
>
> > Kill_Distro = True
> > MatPlotLib_Wanted = True
>
> > from distutils.core import setup
> > import py2exe
> > import sys
> > subdirs = [ '..\\P24_support', '..\\P24_pictures',
> > '..\\P24_Lib_Extensions' ]
> > for subdir in subdirs:
> >   if not ( subdir in sys.path) : sys.path.append ( subdir )
>
> > from file_support import *
>
> > import shutil
> > import glob
>
> > # ***********************************************************************
> > # Some suggests that old build/dist should be cleared
> > # ***********************************************************************
> > dist_paths =  [ 'D:\\Data_Python\\P24_PyLab_Works\\build',
> >                 'D:\\Data_Python\\P24_PyLab_Works\\dist' ]
> > for path in dist_paths :
> >   if File_Exists ( path ) :
> >     shutil.rmtree ( path )
> > # ***********************************************************************
>
> > # ***********************************************************************
> > # ***********************************************************************
> > data_files = []
> > packages = []
> > includes = []
> > excludes = []
> > dll_excludes = []
> > data_files.append ( ( '', glob.glob ( 'templates_*.*' ) ) )
>
> > # ***********************************************************************
> > # For MatPlotLib
> > # ***********************************************************************
> > 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\\*.*' )))
>
> >   excludes.append ( '_gtkagg')
> >   excludes.append ( '_tkagg' )
> >   excludes.append ( '_agg2'  )
> >   excludes.append ( '_cairo' )
> >   excludes.append ( '_cocoaagg' )
> >   excludes.append ( '_fltkagg' )
> >   excludes.append ( '_gtk' )
> >   excludes.append ( '_gtkcairo')
> >   excludes.append ( 'backend_qt' )
> >   excludes.append ( 'backend_qt4')
> >   excludes.append ( 'backend_qt4agg' )
> >   excludes.append ( 'backend_qtagg' )
> >   excludes.append ( 'backend_cairo' )
> >   excludes.append ( 'backend_cocoaagg' )
> >   excludes.append ( 'Tkconstants' )
> >   excludes.append ( 'Tkinter' )
> >   excludes.append ( 'tcl' )
> >   excludes.append ( "_imagingtk" )
> >   excludes.append ( "PIL._imagingtk" )
> >   excludes.append ( "ImageTk" )
> >   excludes.append ( "PIL.ImageTk" )
> >   excludes.append ( "FixTk" )
>
> >   dll_excludes.append ( 'libgdk-win32-2.0-0.dll' )
> >   dll_excludes.append ( 'libgdk_pixbuf-2.0-0.dll' )
> >   dll_excludes.append ( 'libgobject-2.0-0.dll')
> >   dll_excludes.append ( 'tcl84.dll' )
> >   dll_excludes.append ( 'tk84.dll' )
> >   dll_excludes.append ( 'tclpip84.dll' )
> > # ***********************************************************************
>
> > # seems not to be found (imported in brick.py)
> > includes.append ( 'PyLab_Works_properties' )
>
> > # ***********************************************************************
> > # ***********************************************************************
>
> > # If run without args, build executables, in quiet mode.
> > if len(sys.argv) == 1:
> >     sys.argv.append("py2exe")
>
> > setup (
> >   windows = ['PyLab_Works.py']  ,
> >   options = {
> >    'py2exe' : {
> >       'includes'     : includes,
> >       'excludes'     : excludes,
> >       'dll_excludes' : dll_excludes,
> >       'packages'     : packages,
> >                }},
> >   data_files = data_files
> >       )
>
> > import subprocess
> > result = subprocess.call (
> >   [ 'P:\Program Files\Inno Setup 4\ISCC.exe',
> >     'D:\Data_Python\P24_PyLab_Works\PyLab_Works.iss'])
>
> > if (result==0) and Kill_Distro :
> >   for path in dist_paths :
> >     if File_Exists ( path ) :
> >       shutil.rmtree ( path )
>
> > Thé essential issue is not to use pylab to do the imports for you,
> > but perform your own imports,
> > this might be a lot of work: in my case the import looks like this
> > (I don't include numerix, because I use numpy),
> > so in my program to distribute, I use this :
>
> > import matplotlib
> > matplotlib.use('WXAgg')
> > from matplotlib.backends.backend_wxagg \
> >   import Toolbar,  FigureManager
> > from matplotlib.backends.backend_wxagg \
> >   import FigureCanvasWxAgg as FigureCanvas
> > from matplotlib        import rcParams, mlab, cm
> > from matplotlib.mlab   import meshgrid
> > from matplotlib.figure import Figure
> > from matplotlib.axes   import Subplot
>
> > hope this might help you somewhat,
> > cheers,
> > Stef
>
> Steve,
>
> Thanks for your help.
>
> Using your code as a starter, I've gone a lot further.  I have now
> gone pass the point where matplotlib was unable to find its
> datafiles.  However, the program now stops because it can't get
> Tkinter started.  The error message in the log says:
>
> Traceback (most recent call last):
>   File "multicolor.py", line 11, in ?
>   File "pylab.pyc", line 1, in ?
>   File "matplotlib\pylab.pyc", line 222, in ?
>   File "matplotlib\backends\__init__.pyc", line 24, in pylab_setup
>   File "matplotlib\backends\backend_tkagg.pyc", line 7, in ?
> ImportError: No module named Tkinter
>
> Any ideas?
>
> Thanks,

BTW: I don't use Tkinter for GUI, I use PythonCard and wxPython.  May
be the Tkinter is invoked by the multicolor.py sample?



More information about the Python-list mailing list