Similar to this question wxPython + PyObjC causes app to crash at the end however there code has more superfluous code.
I have the following two samples of code, the latter crashes the former runs fine.
The only difference in the code is the order of the imports.
This code runs fine.
import time
# note that the line is before this is so the code does work this is the only
# change that seems to matter
# need the following line to be AFTER wx import otherwise runs fine
import objc # or import Foundation or probably any objc library
import wx
# need the following line
app = wx.App(redirect=False)
# sleep shows it is ONLY when the code finally ends not before
time.sleep(3)
# you don't even need the MainLoop call
This code runs segfaults when program stops running.
import time
import wx
# need this line to be AFTER wx import otherwise runs fine
import objc # or import Foundation or probably any objc library
# need the following line
app = wx.App(redirect=False)
# sleep shows it is ONLY when the code finally ends not before
time.sleep(3)
# you don't even need the MainLoop call
How to replicate
- Make sure pyobjc is installed and you can import objc
- Make sure wxPython is installed (it seems both 2.9 and 3.0 are effected)
- run command python file