I create my first Python (and thus first wxPython) app at https://github.com/marcelstoer/nodemcu-pyflasher. The setup, splash screen and about screen are “heavily inspired” by the excellent wxPython demo app.
The app runs fine and all but when I build an executable with PyInstaller it fails to start with
./src/common/stdpbase.cpp(62): assert “traits” failed in Get(): create wxApp before calling this
That was mentioned here a few years ago at https://groups.google.com/forum/#!msg/wxpython-users/9LHRDqWAOdI/Ml6aHzqmFgEJ;context-place=forum/wxpython-users. However, my (wx)Python know-how is too limited to make much sense of it.
When the app is started I see the initial messages from Main.py:15-17 and after that there’s the above error.
Does anyone have some clues for me?
comment your debugging stuff or move it after
app = App(False) line.
Cheers
Claudia
···
From my understanding you should either
Interesting, what brought you to this conclusion?
I tried both (moving / removing) but it still fails with the same error. I also removed the obsolete main stuff at lines 330ff but that makes no difference either.
I’m now convinced that this has got nothing to do with my specific application. Building the straight-from-the-book plain wxPython Hello World shows exactly the same behavior when built with PyInstaller.
./src/common/stdpbase.cpp(62): assert “traits” failed in Get(): create wxApp before calling this
Segmentation fault: 11
Is this related to my Python/wxPython/PyInstaller installation? Or OS (macOS)? I’m sure that someone familiar with the wxPython source can explain why this function from stdpbase.cpp is called any why it behaves the way it does?
wxStandardPaths& wxStandardPathsBase::Get()
{
wxAppTraits * const traits = wxTheApp ? wxTheApp->GetTraits() : NULL;
wxCHECK_MSG( traits, gs_stdPaths, wxT("create wxApp before calling this") ); # <-- line 62
return traits->GetStandardPaths();
}
Sorry, I guess I was confused when writing this.
I don’t know why but I had in my mind that you are
creating wx objects before creating the App component itself.
Sorry for wasting your time.
Cheers
Claudia
Just for your information
Successfully installed pyInstaller-3.2
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import wx
wx.version()
‘3.0.2.0 gtk2 (classic)’
pyinstaller -F DEMO_HELLO_WORLD.py
created a binary which run successful.
Which version do you use?
Cheers
Claudia
PyInstaller: 3.2
Python: 2.7.12
Just like you. However, you need to run PyInstaller with “–windowed” to create a real GUI application. Did you try the Hello-World I linked to?
Yes, with a minor modification as I’m using multiple versions.
Screenshot
Cheers
Claudia
I’ve downloaded your app and built it with --windowed successfully on linux
NodeMCU PyFlasher
Cheers
Claudia
Thanks a lot for testing! It confirms my suspicion that I picked the wrong forum
Heading over to PyInstaller now.