I'm trying to drive the motors from my RPi4.

On the RPi4 4GB RAM, I installed Ubuntu 21.04.

Here is the code, it used to be working on RPi Buster OS

# import os
# os.environ['GPIOZERO_PIN_FACTORY'] = os.environ.get('GPIOZERO_PIN_FACTORY', 'pigpio')

import time
# from gpiozero.pins.pigpio import PiFactory
from gpiozero import Motor, Device
#Device.pin_factory = PiFactory()
# from gpiozero.pins.native import  LocalPiFactory
# from gpiozero.pins.rpigpio import LocalPiFactory
# from gpiozero.pins.rpio import LocalPiFactory
# from gpiozero.pins.lgpio import LocalPiFactory

# ###
# drive motor: 0.5 - 1, turn motor : 0.2 -1
# ###
class Car:
    BACK = 'BACK'
    LEFT = 'LEFT'

    def __init__(self) -> None:
        self.motor_drive = Motor(6,13)
        self.motor_turn = Motor(12,16)
        self.turn_low_power = 0.2
        self.turn_high_power = 0.8
        self.step = (self.turn_high_power - self.turn_low_power) / 100.0

But once I changed the OS to Ubuntu 21.04, it stopped working.

Searched and found that I need to set up environment variables e.g. GPIOZERO_PIN_FACTORY and also need to install gpiozero and pigpio and I pip installed them and tried to use code to set the pin factory as you could see in the commented code etc.

But none of them works. An error shows: NotImplemented on this line: self.motor_drive = Motor(6,13) enter image description here

Could someone show me how to make it work on Ubuntu 21.04?

update 1

I am told that Ubuntu 21.10 has support for gpio, so I tried to upgrade to it from 21.04 by following a tutorial, I need to use the -d to get the 21.10 as it's not officially released for RPi platform.

But got the endless errors enter image description here

Update 2

Finally updated to Ubuntu 21.10, but the code still not work: enter image description here

So Ubuntu 21.10 does not support gpiozero by default. Also tried to remove the environment variable in the code, still errorred out.

Anyone could help?

  • You need to use Ubuntu 21.10 which added proper GPIO support via the lgpio pin library. Read about it here: waldorf.waveform.org.uk/2021/the-pins-they-are-a-changin.html Commented Oct 1, 2021 at 15:01
  • hi @ben_nuttall thanks for your reply. I have read through the article you provided but not found Ubuntu 21.10 Impish mentioned in that article, but it does mention the Ubuntu Hirsute which is 21.04. Did I miss something?
    – Franva
    Commented Oct 2, 2021 at 0:25
  • @ben_nuttall I'm upgrading my RPi OS to Ubuntu 21.10 anyway. It's worthy to mention that 21.10 is not officially released for RPi, so I need to use the -d parameter to get it.
    – Franva
    Commented Oct 2, 2021 at 0:31
  • hi @ben_nuttall it's failed, please see my Update 1
    – Franva
    Commented Oct 2, 2021 at 0:38
  • hi @ben_nuttall I have tried, upgrading to 21.10 does not help.
    – Franva
    Commented Oct 2, 2021 at 2:33

1 Answer 1


According to this page, (https://ubuntu.com/download/raspberry-pi) 20.04.3 and 21.10 servers and 21.10 desktop are supported for 64-bit operation. I have the desktop running on a RPi4 8GB

  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Oct 28, 2021 at 17:09
  • Hi mark, thanks for ur post, but I was asking the issue about GPIOZero issue, not about whether RPi supports Ubuntu or not.
    – Franva
    Commented Oct 29, 2021 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.