Hi,

Did some more testing with the "http://matplotlib.org/examples/user_interfaces/embedding_in_wx5.html"; example and see the same problem/crash.

Attached the slightly adapted version of the script (using wxPython 2.9 and wx.App instead of wx.SimpleApp which is deprecated in 2.9) and the setup.py script I used to generated the py2exe'd version.

The py2exe'd version works without problem on my Intel Core i5 but crashes on an AMD Athlon 2400+ equiped PC.

Anyone has some tips, ideas on how to track this down?

Best regards
Werner


On 11/03/2013 20:02, Werner F. Bruhin wrote:
Hi,

Some time ago I tried to upgrade from an old version of mpl 0.99 to 1.0
but couldn't get it to work with py2exe and running on a Athlon PC.

I finally got around to upgrade things and have another go at this.

I am now on:
Python 2.7
Numpy 1.6.1  /arch nosse
mpl 1.2.0

I see a hard crash on the Athlon PC (i.e. no traceback and the MS Win
error "App encountered a problem, do you want to report to MS".

Trying to narrow it down I don't think it has to do with numpy as I use
it elsewhere in the app together with wxPython/FloatCanvas without any
issue and when I track where the crash is happening with print
statements it happens on this line:

          print 'plot panel 1'

          # initialize matplotlib stuff
          self.figure = mpl.figure.Figure(figsize=(5, 4), dpi=75,
                                          facecolor='white',
edgecolor='white')
          print 'plot panel 2'

I still see the first print statement but not the second, my imports are
as follows:

import matplotlib as mpl
mpl.use('WXAgg')
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as
FigureCanvas

I know I don't provide a lot of information (at least not yet), but has
anyone come across some similar crash with py2exe and mpl when one
creates a Figure?

Any tips on how to further narrow this down or even better on what is
needed to fix it are very welcome.

Best regards
Werner

------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users



# Used to guarantee to use at least Wx2.8
import sys
if not hasattr(sys, 'frozen'):
    import wxversion
    wxversion.ensureMinimal('2.9')

import wx
import wx.aui
import matplotlib as mpl

print wx.VERSION_STRING
print mpl.__version__

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas
from matplotlib.backends.backend_wxagg import NavigationToolbar2Wx as Toolbar

class Plot(wx.Panel):
    def __init__(self, parent, id = -1, dpi = None, **kwargs):
        wx.Panel.__init__(self, parent, id=id, **kwargs)
        self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2,2))
        self.canvas = Canvas(self, -1, self.figure)
        self.toolbar = Toolbar(self.canvas)
        self.toolbar.Realize()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.canvas,1,wx.EXPAND)
        sizer.Add(self.toolbar, 0 , wx.LEFT | wx.EXPAND)
        self.SetSizer(sizer)

class PlotNotebook(wx.Panel):
    def __init__(self, parent, id = -1):
        wx.Panel.__init__(self, parent, id=id)
        self.nb = wx.aui.AuiNotebook(self)
        sizer = wx.BoxSizer()
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.SetSizer(sizer)

    def add(self,name="plot"):
        page = Plot(self.nb)
        self.nb.AddPage(page,name)
        return page.figure


def demo():
    app = wx.App()
    frame = wx.Frame(None,-1,'Plotter')
    plotter = PlotNotebook(frame)
    axes1 = plotter.add('figure 1').gca()
    axes1.plot([1,2,3],[2,1,4])
    axes2 = plotter.add('figure 2').gca()
    axes2.plot([1,2,3,4,5],[2,1,4,2,3])
    #axes1.figure.canvas.draw()
    #axes2.figure.canvas.draw()
    frame.Show()
    app.MainLoop()

if __name__ == "__main__":
    demo()
# -*- coding: utf-8 -*-#
#-----------------------------------------------------------------------------
# Name:        setup.py
# Purpose:     py2exe build script
#
#              Based on the one from version 3
#-----------------------------------------------------------------------------
# force correct versions
import sys

import wxversion
wxversion.select('2.9.5')

# ======================================================#
# File automagically generated by GUI2Exe version 0.2
# Andrea Gavana, 01 April 2007
# ======================================================#

# Let's start with some default (for me) imports...

from distutils.core import setup
import py2exe
import glob
import os
import sys
import zlib
import shutil

# get base path of wx
import wx
wxPath, wxFileLoc = os.path.split(wx.__file__)

def get_manifest_resource(progname):
    # Putting a manifest resource in the executable allows it to use the
    # XP look-and-feel.
    manifest_template = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    version="5.0.0.0"
    processorArchitecture="x86"
    name="%(prog)s"
    type="win32"
  />
  <description>%(prog)s</description>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
            level="asInvoker"
            uiAccess="false">
        </requestedExecutionLevel>
      </requestedPrivileges>
    </security>
  </trustInfo>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
            type="win32"
            name="Microsoft.VC90.CRT"
            version="9.0.21022.8"
            processorArchitecture="x86"
            publicKeyToken="1fc8b3b9a1e18e3b">
      </assemblyIdentity>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="X86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
  </dependency>
</assembly>
"""
    RT_MANIFEST = 24

    return (RT_MANIFEST, 1, manifest_template % dict(prog=progname))


class Target(object):
    """ A simple class that holds information on our executable file. """
    def __init__(self, **kw):
        """ Default class constructor. Update as you need. """
        self.__dict__.update(kw)


# Ok, let's explain why I am doing that.
# Often, data_files, excludes and dll_excludes (but also resources)
# can be very long list of things, and this will clutter too much
# the setup call at the end of this file. So, I put all the big lists
# here and I wrap them using the textwrap module.

data_files = []

includes = []
excludes = ['_gtkagg', '_tkagg', 'bsddb', 'curses', 'pywin.debugger',
            'pywin.debugger.dbgcon', 'pywin.dialogs', 'tcl',
            'Tkconstants', 'Tkinter', "_tkinter", 'pydoc', 'doctest', 'test',
            'sqlite3',
             # this is used to control if we are in dev mode, e.g. different db etc
            'configdev',
            ]
packages = ['twcbsrc', 'email', 'amara', 'kinterbasdb', 'setuptools',
            'sqlalchemy', 'wx.lib.pubsub', 'PythonReports', 'reportlab']

# need to exclude fb*.dll and ic*.dll, otherwise we get two copies
dll_excludes = ['libgdk-win32-2.0-0.dll', 'libgobject-2.0-0.dll', 'tcl84.dll',
                'tk84.dll', 'fbclient.dll', 'icudt30.dll', 'icuin30.dll', 'icuuc30.dll',
                'mswsock.dll', 'powrprof.dll', # needed to build on Win7 64 and run elsewhere
                'MSVCP90.dll']
icon_resources = []
bitmap_resources = []
other_resources = []


# This is a place where the user custom code may go. You can do almost
# whatever you want, even modify the data_files, includes and friends
# here as long as they have the same variable name that the setup call
# below is expecting.

baseFolder = os.getcwd()
distDir = os.path.join(baseFolder, 'mpltest')

# matplotlib data
# use mpl's get_py2exe_datafiles()
import matplotlib as mpl
data_files += mpl.get_py2exe_datafiles()

# The following will copy the MSVC run time dll's
# (msvcm90.dll, msvcp90.dll and msvcr90.dll) and
# the Microsoft.VC90.CRT.manifest which I keep in the
# "Py26MSdlls" folder to the dist folder
#
# depending on wx widgets you use, you might need to add
# gdiplus.dll to the above collection

py26MSdll = glob.glob(r"c:\Dev\Py26MSdlls-9.0.21022.8\msvc\*.*")
py26MSdll += glob.glob(wxPath+"\\gdiplus.dll")
# install the MSVC 9 runtime dll's into the application folder
##data_files += [("", py26MSdll),]

# I found on some systems one has to put them into sub-folders.
data_files += [("Microsoft.VC90.CRT", py26MSdll),
               ("lib\Microsoft.VC90.CRT", py26MSdll)]

licFiles = glob.glob(baseFolder+"\\dist-license\\*")


# Ok, now we are going to build our target class.
# I chose this building strategy as it works perfectly for me :-D

GUI2Exe_Target_1 = Target(
    # what to build
    script = "wxembedding-5.py",
    bitmap_resources = bitmap_resources,
    other_resources = [get_manifest_resource("Matplot crash test")],
    dest_base = "mpl_test",
    version = '1.0',
    company_name = "Werner",
    copyright = "who ever",
    name = "mpl test script"
    )

# That's serious now: we have all (or almost all) the options py2exe
# supports. I put them all even if some of them are usually defaulted
# and not used. Some of them I didn't even know about.

setup(

    data_files = data_files,

    options = {"py2exe": {"compressed": 2,
                          "optimize": 1, # do not use 2 causes issues with pubsub
                          "includes": includes,
                          "excludes": excludes,
                          "packages": packages,
                          "dll_excludes": dll_excludes,
                          "bundle_files": 2,
                          "dist_dir": distDir,
                          "xref": False,
                          "skip_archive": False,
                          "ascii": False,
                          "custom_boot_script": '',
                         }
              },

    zipfile = r'lib\library.zip',
    #console = [GUI2Exe_Target_1c,],
    windows = [GUI2Exe_Target_1,] #, GUI2Exe_Target_3]
    )

# This is a place where any post-compile code may go.
# You can add as much code as you want, which can be used, for example,
# to clean up your folders or to do some particular post-compilation
# actions.

# post compile code

print 'done'
# And we are done. That's a setup script :-D
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester  
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the  
endpoint security space. For insight on selecting the right partner to 
tackle endpoint security challenges, access the full report. 
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to