Build wxPython On Raspberry Pi Bookworm
set pyenv to your python version:
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install <your python version>
example: env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.10.16
switch to your project directory:
cd ~/<Project>
pyenv local 3.10.16
First update these following Package for you PI:
sudo apt install python3-dev libgtk2.0-dev libgtkd-3-dev
sudo apt install python3-wxgtk4.0 wxglade python-wxtools
sudo apt install dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev libgstreamer-plugins-base1.0-dev libnotify-dev freeglut3-dev libwebkitgtk-6.0-dev libghc-gtk3-dev libwxgtk3.2-dev libwxgtk-gl3.2-1 ibwebkit2gtk-4.0-dev
create virtualenv with pipenv:
python3 -m pipenv shell
Start Build wxPython in your PI:
python3 -m pip download wxpython==4.2.1
tar xf wxPython-4.2.1.tar.gz
start build process in wxPython-4.2.1 folder:
cd wxPython-4.2.1
python3 -m pip install -r requirements.txt
python3 build.py build bdist_wheel --jobs=2
Created .whl file is in ~/wxPython-4.2.2/dist/
andie@raspi-dev02:~/projects/demo-02/wxPython-4.2.2/dist $ python3
Check Installation of wxpython:
Python 3.10.16 (main, Apr 20 2025, 09:26:24) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import wx
>>> print(wx.VERSION)
(4, 2, 1, '')
Ref: