This walkthrough installs the native Gentoo packages for wxPython and wxGTK, sets the needed USE flags, verifies the Python target, and finishes with a working GUI test.
Refresh the tree first, then update installed packages so the dependency graph is current before building wxPython.
sudo emerge --sync
sudo emerge -uDN @world
These USE flags give you the GTK/X11/OpenGL support usually needed for a full desktop wxPython install on Gentoo.
sudo mkdir -p /etc/portage/package.use
cat <<'EOF' | sudo tee /etc/portage/package.use/wxpython
x11-libs/wxGTK gtk3 X opengl
dev-python/wxpython gtk3 X opengl
EOF
If you prefer editing manually, put the same two lines into your chosen
file under /etc/portage/package.use/.
Install the wxWidgets GTK backend first.
sudo emerge --ask x11-libs/wxGTK
This provides the native wxWidgets libraries that wxPython binds to.
Install the Python bindings from the Gentoo tree.
sudo emerge --ask dev-python/wxpython
This is the package that provides the wx module for Python.
If Portage complains about Python targets, confirm which interpreter is active and set the one you want.
eselect python list
sudo eselect python set python3.X
Replace python3.X with the installed version shown on your system.
If you changed the selected interpreter or fixed USE flags, rebuild the wxPython package cleanly.
sudo emerge -1 dev-python/wxpython
Make sure Python can import wx successfully.
python3 -c "import wx; print(wx.version())"
If that prints a wxPython version string, the install is working.
Launch a tiny test window to confirm GUI rendering works.
python3 - <<'EOF'
import wx
app = wx.App(False)
frame = wx.Frame(None, title="wxPython Working", size=(420, 220))
panel = wx.Panel(frame)
wx.StaticText(panel, label="wxPython is installed on Gentoo.", pos=(90, 90))
frame.Show()
app.MainLoop()
EOF
If build dependencies are missing:
sudo emerge --ask dev-python/numpy dev-python/pillow dev-python/sip
If you want to force X11 instead of Wayland-related behavior:
echo "x11-libs/wxGTK X -wayland" | sudo tee -a /etc/portage/package.use/wxpython
If you want binary packages when available:
sudo emerge --getbinpkg dev-python/wxpython
After these steps, Gentoo should have the native wxWidgets GTK backend and Python bindings installed, ready for desktop GUI development with wxPython.