Python 如何创建包含gpiozero的可执行文件?

Python 如何创建包含gpiozero的可执行文件?,python,raspberry-pi,pyinstaller,gpiozero,Python,Raspberry Pi,Pyinstaller,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/_M

我用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 
/tmp/\u MEIFanWCr/gpiozero/devices.py:279:PinFactoryFallback:rpigpio的后退:没有名为“gpiozero.pins.rpigpio”的模块
/tmp/_MEIFanWCr/gpiozero/devices.py:279:PinFactoryFallback:从rpio后退:没有名为“gpiozero.pins.rpio”的模块
/tmp/_MEIFanWCr/gpiozero/devices.py:279:PinFactoryFallback:从pigpio后退:没有名为“gpiozero.pins.pigpio”的模块
/tmp/_MEIFanWCr/gpiozero/devices.py:279:PinFactoryFallback:从本机后退:没有名为“gpiozero.pins.native”的模块
回溯(最近一次呼叫最后一次):
文件“mytk.py”,第8行,在
文件“gpiozero/devices.py”,第124行,在调用中__
文件“gpiozero/output_devices.py”,第211行,in_uuinit__
文件“gpiozero/output_devices.py”,第93行,in_uuinit__
文件“gpiozero/mixins.py”,第106行,在__
文件“gpiozero/devices.py”,第512行,在__
文件“gpiozero/devices.py”,第243行,在__
文件“gpiozero/devices.py”,第280行,在默认引脚工厂中
gpiozero.exc.BadPinFactory:无法加载任何默认pin工厂!
[1597]无法执行脚本

如何创建包含gpiozero的可执行文件?

我们必须这样编写:

from gpiozero.pins.native import NativeFactory
from gpiozero import LED

factory = NativeFactory()
led = LED(12, pin_factory=factory)