无法导入名称gpio?

2024-05-07 07:02:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我在DebianLinux上遇到这个错误。“文件”应用程序副本“第2行输入 从pyA20.gpio导入gpio ImportError:无法导入名称gpio

我不明白为什么它不起作用。在下面的灵盖说这个代码有效。。。但我的不是。怎么了? https://diyprojects.io/orange-pi-onelite-tutorial-use-gpio-python-pinouts/#.Wh75RrT1XKJ

谢谢。在

#import the library / Import des librairies
from pyA20.gpio import gpio
from pyA20.gpio import port
from time import sleep

#initialize the gpio module / initialise le GPIO
gpio.init()

#setup the port (same as raspberry pi's gpio.setup() function)
#Configure la broche PG7 (equivalent au GPIO21 du Raspberry) comme une sortie
gpio.setcfg(port.PG7, gpio.OUTPUT)

#now we do something (light up the LED)
#Maintenant, on allume la LED
gpio.output(port.PG7, gpio.HIGH)

#turn off the LED after 2 seconds
#Et on eteint après 2 secondes
sleep(2)
gpio.output(port.PG7, gpio.LOW)

Tags: thefromimportoutputledgpioonport