Windows locale error: wx._core.wxAssertionError

Hi, I’m using GRASS, a GIS application created using wxPython. Every time I try to load a dataset, I get the following error:
C:\Users\Ishan Buxy>Traceback (most recent call last):
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\”, line 105, in OnInit
mainframe = GMFrame(parent=None, id=wx.ID_ANY,
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\lmgr\”, line 141, in init
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\lmgr\”, line 268, in _createMenuBar
self.menubar = GMenu(
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\gui_core\”, line 47, in init
self.Append(self._createMenu(child), child.label)
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\gui_core\”, line 61, in _createMenu
self._createMenuItem(menu, label=child.label, **data)
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\gui_core\”, line 88, in _createMenuItem
File “C:\Program Files\GRASS GIS 7.8\gui\wxpython\icons\”, line 96, in GetBitmap
image = wx.Image(name=self.imagepath)
wx._core.wxAssertionError: C++ assertion “strcmp(setlocale(0, 0), “C”) == 0” failed at D:\src\osgeo4w\src\wxwidgets\wxwidgets-3.1.5-0df1d81acd6f1be8624022f8eecb51679008ca40\src\common\intl.cpp(1694) in wxLocale::GetInfo(): You probably called setlocale() directly instead of using wxLocale and now there is a mismatch between C/C++ and Windows locale.
Things are going to break, please only change locale by creating wxLocale objects to avoid this!
OnInit returned false, exiting…

Does anyone know how to resolve this?

I have struggled with locale issues with Python 3+ and wxPython 4.0+ and the only way I have discovered to solve the problem completely is to initialize the app as follows:

import locale
# Initialize the app first
app = wx.App(False)
# Now force the locale to the "compatible" 'C' locale
locale.setlocale(locale.LC_ALL, 'C')

This is wrong (but unfortunately the gist of the only
solution). Wrong because it will make Python code that’s
running “below” wxPython behave locale-INsensitive.

And sometimes we can’t even follow the “advice”: “So, use
wx.Locale() already”:

Let’s say you’ve got a Python module which uses string
formatting, which is locale dependant (say, the
thousands-separator). Now, if you re-set

locale.setlocale(locale.LC_ALL, 'C')

after initializing wx.App() that string formatting module
will fail to provide proper output.

I strongly believe wxPython should only attempt to
auto-init the locale if it is “C” when tested upon startup.
Otherwise, set it to whatever already exists (because that is
what earlier Python code had set it to !).


This should be corrected to

… wxWIDGETS should only attempt to …