You Need Python 3 and pip3

To run CircuitPython BLE libraries on a host computer, you'll need at least Python 3.7, and you'll need the pip3 program to install the libraries. You may have pip already, but often the pip (not pip3) command installs software for Python 2, so make sure you are using pip3.

Windows 10

As of this writing (October 2020), the latest Python available on Windows is Python 3.9. But the third-party libraries we are using for BLE on Windows are not yet compatible with Python 3.9. So choose Python 3.8, not 3.9, to install.

You can install Python from https://python.org, or from the Windows Store. See our guide Using Python on WIndows 10 for an easy way to get Python installed.

If you don't use the Windows Store version, make sure you check the box to add Python to your PATH when you run the installer. See the screenshot below.

Starting Python 3 on Windows

Depending on how you install Python 3, the command to start it in a command shell in Windows can be different.

  • Installed from the https://python.org download:
    • Works: python (python.exe)
    • Works:py (py.exe, the Python launcher).
    • Does not work: python3 (python3.exe). You'll get directed to the Windows Store to install Python 3 yet again.
  • Installed from the Windows Store:
    • Works: python (python.exe)
    • Does not work: py (the Python launcher is not installed).
    • Works: python3 (python3.exe).

These differences can be confusing; see this page for detailed documentation.

MacOS

Modern MacOS comes with Python 3, but it may be an older version. Instead of using the system-supplied version, we recommend that you use the Homebrew system to install a more recent version of Python 3 and keep it up to date. The Homebrew installation will not interfere with the system-installed Python, and does not replace it.

This article describes in detail various ways of managing Python on MacOS. It's worth reading to understand the issues, and to see various ways of managing multiple versions of Python.

Linux

Modern versions of Linux always come with Python. They may include both Python 2 and Python 3. See if the version supplied with your Linux distribution is at least 3.7, and preferably 3.8. If not, your distribution may allow you to install additional versions that do not interfere with the original system-supplied version. If you can upgrade your distribution, considering doing so. For instance, Ubuntu 20.04 comes with Python 3.8.

Make sure you have pip3 installed as well, by trying to run it. If it's not installed, install it in the appropriate way for your Linux distribution. For instance, for Ubuntu and Debian, do:

Download: file
sudo apt install python3-pip

Raspberry Pi OS

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.

If you are using Raspberry Pi OS Lite, it may not come with pip3. You'll need to install it by doing: 

Download: file
sudo apt install python3-pip
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.

This guide was first published on Oct 27, 2020. It was last updated on Oct 27, 2020.

This page (Install Python on Your Host Computer) was last updated on Nov 06, 2020.