Update:
sudo apt update && sudo apt upgrade
Enable SPI:
sudo raspi-config > Interface options
Set permissions:
sudo usermod -a -G i2c,spi,gpio pi(substituting your username for pi)
Install example pre-requisites:
sudo apt install python3-dev python3-pip python3-numpy libfreetype6-dev libjpeg-dev build-essential
sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev
Download the examples:
git clone https://github.com/rm-hull/luma.examples.git
Create virtual environment:
python3 -m venv ~/luma-env --system-site-packages
Install the library into the virtual environment:
~/luma-env/bin/python -m pip install --upgrade luma.oled
Navigate to the examples directory:
cd ~/luma.examples/examples/
Run an example:
~/luma-env/bin/python bounce.py --display sh1106 --height 128 --rotate 2 --interface spi --gpio-data-command 9 --spi-device 0
(or --spi-device 1 for the front slot)