Raspberry Pi OS (the new name for Raspian), which is based on Debian Linux, also comes with Python. The latest version as of this writing, buster, comes with Python 3.7, invoked with the python3 command. It also comes with Python 2.7, invoked as python. Do not use Python 2 for this guide.

This guide assumes that you are using the "full" version of Raspberry Pi OS that boots to a desktop operating system, that way you can play YouTube videos in the browser.

We assume that you've already got your Pi set up, Pi OS (Raspbian) Full installed, keyboard and monitor attached, and you're logged in with WiFi/Ethernet networking set up you know your way around a Terminal command line

Do not use sudo when running pip3.

Do Not Use sudo When Running pip3

You may see Internet advice to install libraries using sudo pip3 on Linux or MacOS. This is in general a bad idea, because you can damage the libraries that the underlying system depends on, and in general end up trashing your system in mysterious ways. Always install using pip3 without sudo. If your pip3 is old, you may need to specify pip3 --user, but these days --user is often the default.

Here's a detailed discussion of why sudo pip3 is a bad idea.

Run the following command to install the required Python packages for the project:

pip3 install --upgrade adafruit-blinka-bleio adafruit-circuitpython-ble adafruit-circuitpython-ble-cycling-speed-and-cadence python-xlib

Add User to bluetooth Group

On Linux, including on Raspberry Pi, you must also add your user to the bluetooth group. Reboot after doing this to ensure your user is added to the group and also to ensure that ~/.local/bin is added to your path (after doing pip3 above). To add yourself to the group, do this (the second command will restart your computer, so save any documents or files first!):

sudo usermod -a -G bluetooth $USER
sudo reboot

Raspberry Pi 4B Firmware Fix

Raspberry Pi 4B boards use different hardware for BLE and WiFi than Raspberry Pi 3B and Pi Zero W boards. There is currently (as of October 2020) a bug in the firmware for the 4B boards, in package bluez-firmware_1.2-4+rpt5_all.deb. You must roll back the firmware package to an earlier version (rpt2) to get one that works. Do this only for 3B+ and 4B boards.

This bug is being tracked here: https://github.com/RPi-Distro/bluez-firmware/issues/6.

The third command will restart your computer, so save any documents or files first!

Anytime you upgrade packages, the incorrect version of this package may be reinstalled. Just run the commands below after an upgrade.
wget http://archive.raspberrypi.org/debian/pool/main/b/bluez-firmware/bluez-firmware_1.2-4+rpt2_all.deb
sudo dpkg --install bluez-firmware_1.2-4+rpt2_all.deb
sudo reboot

This guide was first published on Dec 02, 2020. It was last updated on Nov 27, 2020.

This page (Set up Raspberry Pi OS) was last updated on Nov 27, 2020.

Text editor powered by tinymce.