Hello,
Im having the same problems reported by James parcell when compiling to and executing from a single executable.
Im using py2exe vs 0.6.6, matplotlib 0.98.0 and numpy 1.1 but the problem is also reproduced with py2exe 0.6.8 and matplotlib 0.98.1 (original, not from enthough).
Python is active python 2.5.2.

I simplified my program to the following script:

from pylab import plot, show

if __name__=='__main__':
    a=[1,2,3,4,5]
    plot(a)
    show()

Py2exe produces an executable as usual but when executing I get the following traceback (same as James):

Traceback (most recent call last):
  File "test.py", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "pylab.pyo", line 1, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "matplotlib\__init__.pyo", line 94, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "matplotlib\rcsetup.pyo", line 13, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "matplotlib\colors.pyo", line 37, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "numpy\__init__.pyo", line 93, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "numpy\add_newdocs.pyo", line 9, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "numpy\lib\__init__.pyo", line 19, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "numpy\lib\financial.pyo", line 78, in <module>
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'


I checked in financial.py as well as in numpy\ma\core.py (the file also reported by James and for which I also could reproduce the traceback after excluding financial.py from importing). It seems that the problem comes from importing the following function scheme (in 'financial.py', 'foo' would be the 'fv' function):

__all__ = ['foo']
defaultext = 'some more'

def foo():
    "doc foo"
    print 'hi'

foo.__doc__ += defaultext + "more doc"


Could some one give a clue on how to solve this problem? Is it a bug to be solved?. I do not completely understand the solution given by Fabio (maybe my english...). Anyway it seems a bit complicated. Im using several different computers at home and at work and I am providing my collaborators (which do not necesarily have Python installed) of compiled scripts  for several task commonly using numpy and matplotlib.


The setup Im using is the following:

from distutils.core import setup
import py2exe
import glob

import matplotlib

setup(
    console=['test.py'],
    options={
             'py2exe': {
                        'packages' : ['matplotlib', 'pytz'],
                        'excludes': ['_gtkagg', '_agg2', '_cairo', '_cocoaagg',
                                     '_fltkagg', '_gtk', '_gtkcairo', ],
                        'dll_excludes': ['libgdk_pixbuf-2.0-0.dll',
                                         'libgobject-2.0-0.dll',
                                         'libgdk-win32-2.0-0.dll',],
                        'compressed': 1,
                        'optimize':2,
                        'bundle_files': 1
                       }
            },
    zipfile = None,
    data_files = [(r'mpl-data', glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\*.*')),
                  (r'mpl-data', [r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\matplotlibrc']),
                  (r'mpl-data\images',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\images\*.*')),
                  (r'mpl-data\fonts',glob.glob(r'C:\Python25\Lib\site-packages\matplotlib\mpl-data\fonts\*.*'))]
)

Date: Thu, 17 Jul 2008 21:52:19 +0200
From: fabio.pliger@gmail.com
To: py2exe-users@lists.sourceforge.net
Subject: [Py2exe-users] NumPy V1.1 Py2Exe V0.6.8

There seems to be a compatibility issue with Numpy V1.1 and Py2Exe V0.6.8
which I have installed on XP along with Python V2.5.2 and SciPy V0.6.0.

The compilation proceeds without incident apart from the usual list of
missing modules but when the executable is run, the following error arises:

Traceback (most recent call last):
File "Magnetic_Data_Processor.py", line 4, in <module>
import matplotlib
File "zipextimporter.pyo", line 82, in load_module
File "matplotlib\__init__.pyo", line 128, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "matplotlib\rcsetup.pyo", line 18, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "matplotlib\colors.pyo", line 37, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "numpy\__init__.pyo", line 93, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "numpy\add_newdocs.pyo", line 9, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "numpy\lib\__init__.pyo", line 19, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "numpy\lib\financial.pyo", line 78, in <module>
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

I've tried removing the import of the finacial module by editing the
lib.__init__ as I don't use the financial module anyway but then it just
proceeds past this to a similar problem with the ma.core module:

File "numpy\ma\core.pyo", line 3273, in <module>
TypeError: unsupported operand type(s) for +=: 'NoneType' and 'str'

I need this ma.core so I'm a bit stuck.

Any help would be very much appreciated. I've tried a number of approaches
and I'm struggling a little. Oh, also python is installed to C:\Python25

Thanks,
James

Did you install scipy with eggs? Enthought distributions historically are "hard" to use with py2exe.

I've managed to easily create executables with the enthought distro ( that includes most of the modules and packages your are having troubles with ) copying all the stuff needed inside site-packages that is not included by py2exe into a folder and then sticking this folder path into sys.path. ( do this into your first script that is launched before importing everything else ) It also works with eggs ( non compressed eggs ). It's not very elegant and either the best solution but at least makes everything work. ;P

Hope this can help you :)

cheers

Fabio


¡Atrévete con Abecedario, el juego del momento! Invita a tus contactos de Messenger y demuéstrales lo que sabes demuéstrales lo que sabes