[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