Warning when opening wxPython GUI

I have made a GUI to control a test setup in our lab.
To distribute it, I have used pyInstaller, which converts the project to an executable file.
The program works the way it should, but unfortunately, a warning appears on some computers every time I open the GUI (see attachment).

Screenshot 2021-11-10 135100 !

I click ‘OK’ and the warning disappears, after which the program works as usual.

I suspect the warning has something to do with wxPython. I have searched around a lot, but can’t figure out what to do about it. Does anyone have any ideas on how to resolve the problem?

Yeah, that’s coming from the wxWidgets logging framework. You should be able to disable that message if desired: wx.Log — wxPython Phoenix 4.1.2a1 documentation

You could also do wx.Log.EnableLogging(False) to disable logging globally.

Thank you for the response.

I tried to disable logging globally but without luck. Do you have any other suggestions as to how the warning could be avoided?

I’m not sure this can be a help,

>>> app.SetAssertMode(wx.APP_ASSERT_SUPPRESS)

Here is the document about it. wx.PyApp — wxPython Phoenix 4.1.2a1 documentation

Or could it be related to this topic? Heap corruption on Windows - #4 by Adarsh

How about updating PyInstaller and Windows 10, or installing the latest redistribution package?

Hello Komoto48g,
Thank you for the suggestions. I tried the solutions, but without any effect. I read the discussion-topic you linked, checked that I have the newest version of PyInstaller and Windows, but I keep getting the same warning.

Sorry that I cannot be a help, but could this be a hint?
I checked how the locale warning occurs. As @swt2c pointed out, it can be disabled by wx.Log.EnableLogging(False). The following code doesn’t give a warning.

import wx
app = wx.App()
wx.Log.EnableLogging(False)
locale = wx.Locale(wx.LANGUAGE_ENGLISH_DENMARK)

But the following code does.

import wx
app = wx.App()
locale = wx.Locale(wx.LANGUAGE_ENGLISH_DENMARK)
wx.Log.EnableLogging(False)

locale-warning
Another possibility is that the pyinstaller embeds locale settings while packaging…

I have tried the posted solutions but without success.
To check if pyinstaller embeds locale settings while packaging I tried to hardcode locale settings (LANGUAGE_ENGLISH) and tried to log it:

wx.Log.EnableLogging(False)
locale = wx.Locale()
locale.Init(language=wx.LANGUAGE_ENGLISH, flags=wx.LOCALE_DONT_LOAD_DEFAULT)
lng = wx.Locale.GetLocale(locale)
lng_avb = wx.Locale.IsAvailable(wx.LANGUAGE_ENGLISH)
Logger.error(f'Language: {lng}\nAvalibility: {lng_avb}')

From the log I can se that the language set to English and that the language is available, but still I get the same error when starting the program up.

To find the cause, it’s a good idea to start with the simplest program, excluding all dependent packages, and see if the problem occurs.
Btw, did you already try @Robin’s prescription?
see: “wxPython4.1.1 Python3.8 locale wxAssertionError - #3 by Robin

import locale
import wx

def check_locale():
    print(locale.getdefaultlocale()) # ('ja_JP', 'cp932')
    print(locale.getlocale())        # (None, None)
    wxloc = wx.GetLocale()           # None
    if wxloc:
        print((wxloc.Locale, wxloc.Name))

class App(wx.App):
    def InitLocale(self):
        import sys
        if sys.platform.startswith('win') and sys.version_info > (3,8):
            import locale
            locale.setlocale(locale.LC_ALL, 'C')
    
    def OnInit(self):
        wx.Log.EnableLogging(False)
        frm = wx.Frame(None)
        frm.Show()
        wx.CallAfter(check_locale)
        return True

app = App()
app.MainLoop()

:memo: InitLocale is called before OnInit.