如何创建包含 gpiozero 的可执行文件?
how create executable file that contains gpiozero?
我在 raspberrypi 中为 GPIO 引脚写了一个这样的脚本
from gpiozero import LED
led = LED(12)
并正确运行。
但是当使用pyinstaller创建可执行文件并执行文件时。我有这个错误:
/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
如何创建包含 gpiozero 的可执行文件?
我们要这样写:
from gpiozero.pins.native import NativeFactory
from gpiozero import LED
factory = NativeFactory()
led = LED(12, pin_factory=factory)
我在 raspberrypi 中为 GPIO 引脚写了一个这样的脚本
from gpiozero import LED
led = LED(12)
并正确运行。 但是当使用pyinstaller创建可执行文件并执行文件时。我有这个错误:
/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
如何创建包含 gpiozero 的可执行文件?
我们要这样写:
from gpiozero.pins.native import NativeFactory
from gpiozero import LED
factory = NativeFactory()
led = LED(12, pin_factory=factory)