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 explanation of how to do it.
- Raspberry Pi
- Python 3.x
- time, lots of time
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
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):
python3 -m venv wx
The first thing you need is wxPython.
Down of the bottom of the choices, you will see “wxPython-4.1.0.tar.gz … Source”.
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.
tar xf wxPython-4.1.0.tar.gz
Next step, make sure you are in the environment you want to install wxPython into.
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.py 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) :
pip3 install wxPython-4.1.0-cp37-cp37m-linux_armv7l.whl
After waiting ~ 1 hour
Now let’s test it: