0

I'm trying out gpiozero, but after running the examples from their documentation, I still get this errors but it still runs ok.

gpiozero is installed on venv using pip3

#!/usr/bin/env python
from gpiozero import Button
from signal import pause

def say_hello():
    print("Hello!")

button = Button(2)

button.when_pressed = say_hello

pause()
/home/pi/gpiozero/venv/lib/python3.7/site-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpigpio: No module named 'RPi'                         
  'Falling back from %s: %s' % (name, str(e))))

/home/pi/gpiozero/venv/lib/python3.7/site-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpio: No module named 'RPIO'                           
  'Falling back from %s: %s' % (name, str(e))))

/home/pi/gpiozero/venv/lib/python3.7/site-packages/gpiozero/devices.py:279: PinFactoryFallback: Falling back from pigpio: No module named 'pigpio'                       
  'Falling back from %s: %s' % (name, str(e))))

If I install RPi.GPIO the error goes away.

  • The real question is WHY you felt the need to install gpiozero - it is included in Raspbian. You have probably nobbled it by installing a private copy. – Milliways Sep 25 '19 at 11:03
  • GPIOZero is a superset of RPi.GPIO. – Dougie Sep 25 '19 at 16:58
  • @Milliways it is not included in Raspbian Lite. I am using venv for my project – sudo Sep 27 '19 at 15:10
  • In which case you should install, following the Foundation instructions sudo apt install python3-gpiozero NOT install a private copy – Milliways Sep 28 '19 at 2:27
2

gpiozero does not need RPi.GPIO. However there is little reason not to install RPi.GPIO, it doesn't take much space and there are a wealth of examples of its usage.

gpiozero can use any one of a number of GPIO library backends to carry out its tasks.

By default it uses RPi.GPIO.

If RPi.GPIO is not installed it defaults to RPIO.GPIO.

If RPIO.GPIO is not installed it defaults to pigpio.

You don't have to exclusively use the default. You can tell gpiozero to use any of the above GPIO libraries (if it's installed) for a specific function.

0

Question

Do I need to install Rpi.GIPIO for GPIO Zero?

Answer

Well, GPIO Zero builds on Rpi.GPIO and other libraries. So if your raspbian does not have it preinstalled, you need to do so.

References

(1) Gpiozero 1.5.1 Documentation > Docs » gpiozero

Pin factories

... GPIO Zero builds on a number of underlying pin libraries, including RPi.GPIO and pigpio, each with their own benefits. You can select a particular pin library to be used, either for the whole script or per-device, according to your needs. See the section on changing the pin factory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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