Standalone program using py2exe don't run om machine without wx installed

64 views
Skip to first unread message

uap12

unread,
Dec 21, 2009, 10:00:46 AM12/21/09
to wxPython-users
Hi!
I have looked around, but if someone already asked, i am sorry but i
can't find it.

i use to write fix and small utilsprogram, but like to write them
using Python,
this works but now i need to have some user-interaction and therefore
i need
GUI, so i looked at wx, and it works nice.

But on the user machine i can't install anything so i looked at py2exe
to
make a single exe-file (this is under Windows), i works fine, but not
on
the user machine, the program just do not start, and i can't find
the problem, becurse i don't get any error, it just not start

is i missing anything build the package or,,

// Anders

Mike Driscoll

unread,
Dec 21, 2009, 12:01:42 PM12/21/09
to wxPython-users
Hi,

I build my wxPython programs using py2exe via GUI2Exe and it works for
the most part. I do not recommend using the Bundle Files = 1 option as
it's more trouble than it's worth. I usually use the following
settings instead:

Optimize = 2
Compressed = 2
Bundle Files= 3

Then I use Inno Setup to bundle everything up into a nice installer. I
wrote a tutorial about the whole process here:

http://www.blog.pythonlibrary.org/2008/08/27/packaging-wxpymail-for-distribution/

Have fun!

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org

werner

unread,
Dec 21, 2009, 12:04:26 PM12/21/09
to wxpytho...@googlegroups.com
On the following wiki page is a small sample.

http://wiki.wxpython.org/Deployment

Hope it helps
Werner

cappy2112

unread,
Dec 21, 2009, 1:30:51 PM12/21/09
to wxPython-users
Inno should not be needed.
When I use py2exe for wx programs, you end up with a huge exe
(shoulnd't really matter) that contains
all the necessary Python & wx modules.

> http://www.blog.pythonlibrary.org/2008/08/27/packaging-wxpymail-for-d...

Steven Sproat

unread,
Dec 21, 2009, 2:02:42 PM12/21/09
to wxpytho...@googlegroups.com
Take a look at GUI2EXE (http://code.google.com/p/gui2exe/) by Andrea and
check the "build" folder that's created after compilation. If you go
through the DLL and .pyd files there you can generally find a lot that
your program won't use . You can then "exclude" these modules to
minimise the file size.

Also UPX (http://upx.sourceforge.net/) can help knock off a MB or more
from your EXE.

Mike Driscoll

unread,
Dec 21, 2009, 2:30:25 PM12/21/09
to wxPython-users
Hi,

On Dec 21, 12:30 pm, cappy2112 <cappy2...@gmail.com> wrote:
> Inno should not be needed.
> When I use py2exe for wx programs, you end up with a huge exe
> (shoulnd't really matter) that contains
> all the necessary Python & wx modules.


Inno isn't needed, but it's a convenience as you can use it to install
anything extra that you need and it provides an uninstaller. Besides
that, I've tried bundling everything into one executable and had
issues with PCs from time-to-time. Most of the time, it worked for me,
but I had 2 or 3 users where it would not run that way.

cappy2112

unread,
Dec 21, 2009, 6:36:34 PM12/21/09
to wxPython-users
I almost always have a problem getting wx-based programs working with
py2exe.
I've used the exclude and exclude_dll options, but those dlls still
get included.
I haven't tried gui2exe though.

Stef Mientki

unread,
Dec 21, 2009, 7:26:18 PM12/21/09
to wxpytho...@googlegroups.com
Py2exe has a problem with a lot of libraries.
I simply use a dummy file, which I add to the execute list.
For wxPython, I use the following part in the dummy file:

import wx
import wx.aui
import wx.grid as gridlib
import wx.html as html
from wx.lib.art import flagart, img2pyartprov
import wx.lib.buttons as buttons
import wx.lib.delayedresult as delayedresult
import wx.lib.flatnotebook as fnb
import wx.gizmos
import wx.lib.iewin as iewin
from wx.lib.expando import ExpandoTextCtrl, EVT_ETC_LAYOUT_NEEDED
import wx.lib.mixins.listctrl as listmix
import wx.lib.newevent
import wx.lib.plot as plot
import wx.lib.wordwrap
import wx.lib.wxpTag
from wx.lib.splitter import MultiSplitterWindow
#GEEFT PROBLEMEN OP UMCN:
#from wx.lib.pdfwin import PDFWindow
import wx.lib.pdfwin
import wx.lib.hyperlink as hl
import wx.py
import wx.richtext
import wx.stc as stc
# aren't copied ??
#import wx.webview


cheers,
Stef

Andrea Gavana

unread,
Dec 22, 2009, 3:14:41 AM12/22/09
to wxpytho...@googlegroups.com
Hi,

2009/12/21 cappy2112:


> I almost always have a problem getting wx-based programs working with
> py2exe.
> I've used the exclude and exclude_dll options, but those dlls still
> get included.

You must be doing something strange then. I have never seen py2exe
including something I explicitely excluded, except when (by mistake) I
added a module both in the include and the exclude lists. The Includes
option is stronger than the Excludes one. So, if a module is present
in both Includes and Excludes, it will be included in your final
distribution.

> I haven't tried gui2exe though.

Give it a try and let me know :-D

Andrea.

"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
http://thedoomedcity.blogspot.com/

Andrea Gavana

unread,
Dec 22, 2009, 3:16:41 AM12/22/09
to wxpytho...@googlegroups.com
Hi,

2009/12/22 Stef Mientki:

All these imports in a dummy file are not needed with py2exe. Whatever
application I have thrown at it (and some of them are hugely complex),
py2exe has always found all the modules needed by it (with few obscure
exceptions, but not wx-related).

Stef Mientki

unread,
Dec 22, 2009, 5:16:07 AM12/22/09
to wxpytho...@googlegroups.com
hi Andrea,

Andrea Gavana wrote:
> Hi,
>
> 2009/12/22 Stef Mientki:
>
>> uap12 wrote:
>>
>>> Hi!
>>>
>>>

>> Py2exe has a problem with a lot of libraries.
>> I simply use a dummy file, which I add to the execute list.
>> For wxPython, I use the following part in the dummy file:
>>
>>

> All these imports in a dummy file are not needed with py2exe. Whatever
> application I have thrown at it (and some of them are hugely complex),
> py2exe has always found all the modules needed by it (with few obscure
> exceptions, but not wx-related).
>

So I guess I always make a mess of my imports,
and probably that's the reason, why I never could get GUI2exe working ;-)

The following packages gave me problems with py2exe (in the past):
wx, win32, Matplotlib, VPython.
And not only with py2exe, but also with autocompletion in PyScripter.
I think wx is better now,
because autocompletion (although not perfect) works better with the
latest versions.
Py2exe has it weakness, until I updated to the latest version (past week),
I always had to run twice, because it couldn't find some files in my root !!

cheers,
Stef

werner

unread,
Dec 22, 2009, 5:17:51 AM12/22/09
to wxpytho...@googlegroups.com
Same here.

Where I have had problems with py2exe is using the bundle options 1 and 2, I just stick with 3 and use InnoSetup to create a single file installer.

Werner

werner

unread,
Dec 22, 2009, 7:12:23 AM12/22/09
to wxpytho...@googlegroups.com
Stef Mientki wrote:
> hi Andrea,
>
> Andrea Gavana wrote:
>
>> Hi,
>>
>> 2009/12/22 Stef Mientki:
>>
>>
>>> uap12 wrote:
>>>
>>>
>>>> Hi!
>>>>
>>>>
>>>>
>>> Py2exe has a problem with a lot of libraries.
>>> I simply use a dummy file, which I add to the execute list.
>>> For wxPython, I use the following part in the dummy file:
>>>
>>>
>>>
>> All these imports in a dummy file are not needed with py2exe. Whatever
>> application I have thrown at it (and some of them are hugely complex),
>> py2exe has always found all the modules needed by it (with few obscure
>> exceptions, but not wx-related).
>>
>>
> So I guess I always make a mess of my imports,
> and probably that's the reason, why I never could get GUI2exe working ;-)
>
> The following packages gave me problems with py2exe (in the past):
> wx, win32, Matplotlib, VPython.
>
What was the issue with win32, I use it a little bit and didn't run into
any problem.

These are my "problems": packages = ['email', 'Ft', 'kinterbasdb',
'pytz', 'setuptools', 'sqlalchemy']

The last three are because they are unzipped egg's, and the others are
doing some dynamic imports which the module finder py2exe uses doesn't
deal with.

IIRC the module finder in py2exe was updated in one of the later
releases which improved things.

Matplotlib isn't a problem anymore, at least for me and I use the
following version.

matplotlib.__version__
'0.99.1'

Except you need to do the following for the data files in your setup.py.
import matplotlib as mpl
data_files += mpl.get_py2exe_datafiles()

IIRC I also had an issue with PIL until I did this in the module I use
it in:
import PIL.PngImagePlugin
import PIL.GifImagePlugin
import PIL.JpegImagePlugin
import PIL.BmpImagePlugin
Image._initialized=2

I think a lot of this stuff is mentioned on the py2exe wiki but there is
also a lot of outdated stuff on there which can be confusing.

Werner

Reply all
Reply to author
Forward
0 new messages