Interesting install issue

So I can install wxpython4.2.2 on windows 10 (latest update) using python 3.10. But when I use python 3.12.6 I get the following issue:
Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] on win32

import wx
Traceback (most recent call last):
File “”, line 1, in
File “C:\Program Files\Python312\Lib\site-packages\wx_init_.py”, line 17, in
from wx.core import *
File “C:\Program Files\Python312\Lib\site-packages\wx\core.py”, line 12, in
from ._core import *
ImportError: DLL load failed while importing _core: The specified module could not be found.

I believe the module is the agw module and it might be something with the gradientbutton. This is the first issue I have seen with wxpython 4.2.2 (I have successfully installed on windows 10 without issue). Sure could use some help here…

Even after doing a windows 10 reset (removed all the files) I have exactly the same error.

Are you sure that the install was successful when you installed wxPython for Python 3.12? There were not any errors?

Positive - no errors at all. Like I said earlier I believe this has something to do with AGW.

If someone would like to contact me I can show them the install etc… Then they can see the error.

I am unclear how that is related to AGW… your traceback shows that your installation breaks in wx._core, which is well before anything in AGW is looked at.

When I try to debug the issue I get an error stating that python can not load the module agw. When I then try to stop the debugger within agw I get an other error which suggest that it can not load gradientbutton. But I have gone down the wrong path many times. So i might be way off base.

Johnf

More info - I installed windows 11 on this computer (intel nuc icore 7) and I get the same error message.

Johnf

I have Windows PC 3.10 and 3.11 home and wxPython 4.2.2 wxWidgets 3.2.6 Sip 6.8.5 and no problem whatsoever :joy:

I have never run into this issue in the past and I have installed python 3.12.6 with wxPython 4.2.2 on at least 50 computers without issue. It is the first time I have run into an issue of this type.

It sounds like no else has had this issue because I haven’t had any leads on how to fix this.

Johnf

Does a simple import wx show the same error?

You installed wxPython globally, not in any sort of virtual environment, correct?

Yes and Yes. The is result of
import wx → core.py which → from ._core import *

When I try to debug the I discover that it has something to do with ‘AGW’. But I could be completely wrong!

Johnf

If import wx fails, it has nothing to do with AGW, like @Andrea_Gavana noted earlier.

What does the contents of C:\Program Files\Python312\Lib\site-packages\wx\ look like?

It looks normal to me. But is there something I should be looking for? There are a lot of files in the folder.

Johnf

You can compare it to the contents of the wxPython wheel file. If you don’t find any missing files, it could possibly be some sort of DLL path search issue, but I don’t really have any further ideas. Maybe someone who knows more about Windows can chime in.

I’d suggest using DependencyWalker (the new one) and load _core.pyd in it to investigate.

Is the problem related to virtual environments? Some people seem to have issues when installing wxPython into a virtual environment.
See e.g. here: can't import wx · Issue #2612 · wxWidgets/Phoenix · GitHub

No virt. And I checked the pyd’s they are there. I have reset the computer. Used the free upgrade to windows 11 and I still have no changes.

Do you guys think a complete wipe of the drive and a complete new install might help?

Johnf

Also I don’t know how to use the DependencyWalker. Also did not find the exe.

did you try something like this :melting_face: ?

try:
    from ._core import *
except ImportError as e:
    print(e)

This is what I get after adding the try in core.py

PS C:\Users\admin> python
Python 3.12.6 (tags/v3.12.6:a4a2d2b, Sep 6 2024, 20:11:23) [MSC v.1940 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

import wx
DLL load failed while importing core: The specified module could not be found.
Traceback (most recent call last):
File “”, line 1, in
File "C:\Python312\Lib\site-packages\wx_init
.py", line 17, in
from wx.core import *
File “C:\Python312\Lib\site-packages\wx\core.py”, line 143, in
BG_STYLE_CUSTOM = BG_STYLE_PAINT
^^^^^^^^^^^^^^
NameError: name ‘BG_STYLE_PAINT’ is not defined