pythonraspberry-pipyinstallergpiozero

how create executable file that contains gpiozero?


i wrote a script like this for GPIO pins in raspberrypi

from gpiozero import LED
led = LED(12)

and Runs correctly. but when create executable file using pyinstaller, and execute file. i have this error:

/tmp/_MEIFanWCr/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpigpio: No module named 'gpiozero.pins.rpigpio'
/tmp/_MEIFanWCr/gpiozero/devices.py:279: PinFactoryFallback: Falling back from rpio: No module named 'gpiozero.pins.rpio'
/tmp/_MEIFanWCr/gpiozero/devices.py:279: PinFactoryFallback: Falling back from pigpio: No module named 'gpiozero.pins.pigpio'
/tmp/_MEIFanWCr/gpiozero/devices.py:279: PinFactoryFallback: Falling back from native: No module named 'gpiozero.pins.native'
Traceback (most recent call last):
  File "mytk.py", line 8, in <module>
  File "gpiozero/devices.py", line 124, in __call__
  File "gpiozero/output_devices.py", line 211, in __init__
  File "gpiozero/output_devices.py", line 93, in __init__
  File "gpiozero/mixins.py", line 106, in __init__
  File "gpiozero/devices.py", line 512, in __init__
  File "gpiozero/devices.py", line 243, in __init__
  File "gpiozero/devices.py", line 280, in _default_pin_factory
gpiozero.exc.BadPinFactory: Unable to load any default pin factory!
[1597] Failed to execute script 

how i can create executable file that contains gpiozero?


Solution

  • We have to write like this:

    from gpiozero.pins.native import NativeFactory
    from gpiozero import LED
    
    factory = NativeFactory()
    led = LED(12, pin_factory=factory)