Dll load fail no ._core module

4.2.1 wxpython and 3.12.2 python

installing wxpython goes fine but when importing I get an error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\wx\__init__.py", line 17, in <module>
    from wx.core import *
  File "C:\Users\User\AppData\Roaming\Python\Python312\site-packages\wx\core.py", line 12, in <module>
    from ._core import *
ImportError: DLL load failed while importing _core: The specified module could not be found.

I wasnt able to fix it using answers on other similar issues, and I have reinstalled wxpython multiple times and installing other python packages works fine

How did you install wxPython? On PIP there seem to be binaries for Python 3.12:
wxPython · PyPI

After installation, you should see following folder and files:

Lib\site-packages\wxPython-4.2.1.dist-info  (folder)
Lib\site-packages\wx\_core.cp312-win_amd64.pyd
Lib\site-packages\wx\wxmsw32u_core_vc140_x64.dll

There is a python folder in my program files and my user folder/appdata/roaming, on my user folder I have all three of those files although in program files/…/site-packages there is only pip and the pip dist-info

I used both pip install wxpython and pip install -U wxPython, both had the same problem

also I downloaded wxpython fine on another device, so it might be from how I got python/pip on this device?

heres is what it says when I installed wxpython

Defaulting to user installation because normal site-packages is not writeable
Collecting wxpython
  Downloading wxPython-4.2.1-cp312-cp312-win_amd64.whl.metadata (3.0 kB)
Collecting pillow (from wxpython)
  Downloading pillow-10.3.0-cp312-cp312-win_amd64.whl.metadata (9.4 kB)
Collecting six (from wxpython)
  Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
Downloading wxPython-4.2.1-cp312-cp312-win_amd64.whl (17.8 MB)
   ---------------------------------------- 17.8/17.8 MB 17.2 MB/s eta 0:00:00
Downloading pillow-10.3.0-cp312-cp312-win_amd64.whl (2.5 MB)
   ---------------------------------------- 2.5/2.5 MB 23.1 MB/s eta 0:00:00
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: six, pillow, wxpython
Successfully installed pillow-10.3.0 six-1.16.0 wxpython-4.2.1

Yes, I could have seen myself that your libraries are installed in AppData…

I have just tried with my Python 3.12 installation and moved wx into AppData\Roaming\Python\Python312\site-packages and things are working fine.
A way to provoke the error is to remove e.g. wxmsw32u_core_vc140_x64.dll.
Unfortunately, I think it’s not possible to identify from the message which DLL is missing.

A .pyd file is a normal DLL.
You may download and run the Dependency Walker to check for problems: https://www.dependencywalker.com/
Use File->Open -> ...\site-packages\wx\_core.cp312-win_amd64.pyd
(This may take 15 minutes to run.)

When I do so, with a removed wxmsw32u_core_vc140_x64.dll, I get this:
grafik

(It’s normal that PYTHON312.DLL is yellow, as it’s not in the same directory.)

It was the MSVCP140.dll being the problem, I didnt have visual c++ installed

import wx works fine now

Well, I was about to ask for the MSVC redistributable, but I thought that the Python DLL would depend on it and so that could not be the problem.

P.S.: There is now a faster alternative to Dependency Walker: Dependencies

This takes only fractions of a second for the analysis:
grafik

1 Like