[wxpython] import error,

Python 3.8.16 (default, Jun 23 2024, 20:41:42)
[GCC 11.4.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import wx
Traceback (most recent call last):
File “”, line 1, in
File “/home/luo/myproject/venv/lib/python3.8/site-packages/wx/init.py”, line 17, in
from wx.core import *
File “/home/luo/myproject/venv/lib/python3.8/site-packages/wx/core.py”, line 12, in
from ._core import *
ModuleNotFoundError: No module named ‘wx._core’
pip list:
Package Version


numpy 1.24.4
pillow 10.3.0
pip 24.1
setuptools 70.1.0
six 1.16.0
wheel 0.43.0
wxPython 4.2.1
pip -V:
pip 24.1 from /home/luo/myproject/venv/lib/python3.8/site-packages/pip (python 3.8)

I don’t know what caused this import error

The code I am sharing snippet acknowledges the import error and suggests checking dependencies and reinstalling wxPython if necessary:

# Importing wxPython
import wx

# Check for any import errors
try:
    from wx.core import *
except ModuleNotFoundError as e:
    print(f"Import error: {e}")

# Check if wxPython is installed correctly
# Ensure dependencies are up-to-date
# Reinstall wxPython if issues persist

first,download the file [wxPython-4.2.1-cp38-cp38-win_amd64.whl ], then change the name :wxPython-4.2.1-cp38-cp38-manylinux_2_35_x86_64.whl
use pip to install :
pip install /home/luo/Downloads/wxPython-4.2.1-cp38-cp38-manylinux_2_35_x86_64.whl
Processing /home/luo/Downloads/wxPython-4.2.1-cp38-cp38-manylinux_2_35_x86_64.whl
Requirement already satisfied: pillow in ./venv/lib/python3.8/site-packages (from wxPython==4.2.1) (10.3.0)
Requirement already satisfied: six in ./venv/lib/python3.8/site-packages (from wxPython==4.2.1) (1.16.0)
Requirement already satisfied: numpy in ./venv/lib/python3.8/site-packages (from wxPython==4.2.1) (1.24.4)
Installing collected packages: wxPython
Successfully installed wxPython-4.2.1

I don’t know much about wheels, but am I right in assuming that wxPython-4.2.1-cp38-cp38-win_amd64.whl is built to run on Windows and will contain binary extensions compiled for Windows?

So how does just renaming it as a wheel for manylinux allow the code to run on linux?

@RichardT is correct - a win_amd64.whl is built for 64-bit x86 Windows and will NOT work on Linux simply by renaming it.

OK.Thank you for your reminding, this problem has been sovled.

Yes,U are right,But the installation shows successfully installed that still makes me a little confused

I am having the same problem. Part of the problem I find frustrating is that most of the answers appear to be coming from wheels experts to wheels experts, and they are suggesting weird things such as renaming .whl files in ways that are nonsensical.

jeffs@frmwrk16:~/Downloads$ pip install --force-reinstall --break-system-packages -U -f $URL wxPython
Defaulting to user installation because normal site-packages is not writeable
WARNING: Skipping /usr/lib/python3.12/dist-packages/charset_normalizer-3.3.2.dist-info due to invalid metadata entry 'name'
Looking in links: https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04
Collecting wxPython
  Using cached https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04/wxpython-4.2.5-cp312-cp312-linux_x86_64.whl (151.2 MB)
WARNING: Skipping /usr/lib/python3.12/dist-packages/charset_normalizer-3.3.2.dist-info due to invalid metadata entry 'name'
Installing collected packages: wxPython
  Attempting uninstall: wxPython
    Found existing installation: wxPython 4.2.5
    Uninstalling wxPython-4.2.5:
      Successfully uninstalled wxPython-4.2.5
Successfully installed wxPython-4.2.5
jeffs@frmwrk16:~/Downloads$ python
Python 3.12.3 (main, Mar  3 2026, 12:15:18) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jeffs/Downloads/wx/__init__.py", line 17, in <module>
    from wx.core import *
  File "/home/jeffs/Downloads/wx/core.py", line 12, in <module>
    from ._core import *
ModuleNotFoundError: No module named 'wx._core'
>>> 

I tried to do some troubleshooting, but my skills are not up to the task.

jeffs@frmwrk16:~/Downloads$ cd wxpython-4.2.5.dist-info/
jeffs@frmwrk16:~/Downloads/wxpython-4.2.5.dist-info$ ls
entry_points.txt  licenses  METADATA  RECORD  top_level.txt  WHEEL
jeffs@frmwrk16:~/Downloads/wxpython-4.2.5.dist-info$ fgrep _core *
grep: licenses: Is a directory
RECORD:wx/_core.cpython-313-x86_64-linux-gnu.so,sha256=hi1p41f69vhH3HweT1KaubUF2F4Q4b5g1h9hmMI9N9A,178562800
RECORD:wx/libwx_gtk3u_core-3.2.so.0,sha256=WYS-8N_bHgED7SzfQw5MoGXbLlfXjOdf0-sQ3JFWL2I,10990192
jeffs@frmwrk16:~/Downloads/wxpython-4.2.5.dist-info$ fgrep _core * */*
grep: licenses: Is a directory
RECORD:wx/_core.cpython-313-x86_64-linux-gnu.so,sha256=hi1p41f69vhH3HweT1KaubUF2F4Q4b5g1h9hmMI9N9A,178562800
RECORD:wx/libwx_gtk3u_core-3.2.so.0,sha256=WYS-8N_bHgED7SzfQw5MoGXbLlfXjOdf0-sQ3JFWL2I,10990192
jeffs@frmwrk16:~/Downloads/wxpython-4.2.5.dist-info$ cd ../wx
jeffs@frmwrk16:~/Downloads/wx$ fgrep -r _core * */* 
grep: _adv.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _aui.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _core.cpython-313-x86_64-linux-gnu.so: binary file matches
core.py:from ._core import *
core.py:    import wx._core
core.py:    atexit.register(wx._core._wxPyCleanup)
core.pyi:#-- begin-_core --#
core.pyi:    import wx._core
core.pyi:    atexit.register(wx._core._wxPyCleanup)
core.pyi:#-- end-_core --#
grep: _dataview.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _glcanvas.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _grid.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _html2.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _html.cpython-313-x86_64-linux-gnu.so: binary file matches
include/wxPython/wxpy_api.h:// via a structure of function pointers that is exported from the wx._core
lib/calendar.py:#   newobj = _core.new_Rect(*args, **kwargs)
lib/evtmgr.py:        return isinstance(anObject, wx._core._wxPyDeadObject)
grep: libwx_gtk3u_aui-3.2.so.0: binary file matches
grep: libwx_gtk3u_core-3.2.so.0: binary file matches
grep: libwx_gtk3u_gl-3.2.so.0: binary file matches
grep: libwx_gtk3u_html-3.2.so.0: binary file matches
grep: libwx_gtk3u_media-3.2.so.0: binary file matches
grep: libwx_gtk3u_propgrid-3.2.so.0: binary file matches
grep: libwx_gtk3u_ribbon-3.2.so.0: binary file matches
grep: libwx_gtk3u_richtext-3.2.so.0: binary file matches
grep: libwx_gtk3u_stc-3.2.so.0: binary file matches
grep: libwx_gtk3u_webview-3.2.so.0: binary file matches
grep: libwx_gtk3u_xrc-3.2.so.0: binary file matches
grep: _media.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _propgrid.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: __pycache__/core.cpython-312.pyc: binary file matches
grep: _ribbon.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _richtext.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _stc.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _xml.cpython-313-x86_64-linux-gnu.so: binary file matches
grep: _xrc.cpython-313-x86_64-linux-gnu.so: binary file matches
include/wxPython/wxpy_api.h:// via a structure of function pointers that is exported from the wx._core
lib/calendar.py:#   newobj = _core.new_Rect(*args, **kwargs)
lib/evtmgr.py:        return isinstance(anObject, wx._core._wxPyDeadObject)
grep: __pycache__/core.cpython-312.pyc: binary file matches
jeffs@frmwrk16:~/Downloads/wx$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu 24.04.4 LTS"
jeffs@frmwrk16:~/Downloads/wx$ 

@jeffsilverm I think part of the problem is that you have a wx directory in your Downloads folder, which contains a suspicious set of files (both Python 3.12 and 3.13??), but it seems you are trying to use an installed wheel? When running import wx Python will usually try the current directory for locating modules to import.

First, I would just try cd’ing out of the Downloads directory and try running your test again.

BTW, using --break-system-packages seems dangerous.