How to build and install wxPython on Raspberry Pi?

If you need to install wxPython on Raspbian Buster for a project, the installation of that module can be a little bit tricky. It needs to be compiled for Raspbian from source files to have something working nicely.

Here you can find step by step explaination how to do it.


  • Raspberry Pi
  • Python 3.x
  • time, lots of time

Step 1

First, you need to open a terminal (shortcut ctrl + alt + t)

sudo apt-get update

sudo apt-get install dpkg-dev build-essential libjpeg-dev libtiff-dev libsdl1.2-dev libgstreamer-plugins-base0.10-dev libnotify-dev freeglut3 freeglut3-dev libwebkitgtk-dev libghc-gtk3-dev libwxgtk3.0-gtk3-dev

if you use the pre-installed Python 3:

sudo apt-get install python3.7-dev

Step 2

Now, let’s make the virtual environment. I made mine right off the /home/pi directory, but you can put it anywhere. Some like to put all their virtual environments (virtenv) in specific locations.

Let’s make one (wx is the name of the virtenv we are creating, change it to suit):

cd ~

python3 -m venv wx

source ~/wx/bin/activate

Step 3

The first thing you need is wxPython.

Go to:

Down of the bottom of the choices, you will see “wxPython-4.1.0.tar.gz … Source”.

Download wxPython-4.1.0.tar.gz

Use your browser if you can. The file should go into your ~/Downloads folder. The link currently is the very human unfriendly:

Okay, that’s not exactly a professional comment but sometimes you just have to call it what it is.

cd ~

mv ~Downloads/wxPython-4.1.0.tar.gz

tar xf wxPython-4.1.0.tar.gz

Next step, make sure you are in the environment you want to install wxPython into.

cd wxPython-4.1.0

pip3 install -r requirements.txt

The next part is the big one. This will take a while, anywhere from a few hours to 18+ hours on a Raspberry Pi Zero.

python3 build bdist_wheel --jobs=1

After waiting ~ 8 hours

Now to install it in Python as a package (the name of this file varies depending on the Python version you build it with. ie. wxPython-4.1.0-cp38-cp38-linux_armv7l.whl for Python 3.8) :

cd ~/wxPython-4.1.0/dist

pip3 install wxPython-4.1.0-cp37-cp37m-linux_armv7l.whl

After waiting ~ 1 hour

Now let’s test it:

cd ~/wxPython-4.1.0.post2/demo



By Marc Dobler

I am 37 years old web enthusiast passionate about coding, who loves to create new things in web mostly using WordPress, with progressive web apps experience that com bine s the best of the web and apps.

Let's discuss about it!