大佬教程收集整理的这篇文章主要介绍了Python3 Raspberry Pi(ModuleNotFoundError:没有名为“RPi”的模块),带有代码和错误,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
enter code here
嗨,我的 raspBerry pi 遇到了这个问题,我试图运行一个程序,但它无法识别“RP”。我已经使用 pip install RPi.GPIO 安装了 RPi。每当我尝试“Sudo apt-get install python-RPI.gpio python3-RPI.gpio”时,它都会说该软件包只能从其他来源获得。所以我安装了这个包,但 python3 似乎无法访问它。如果您知道如何解决此问题,请提供帮助。
#!/usr/bin/env python3
########################################################################
# filename : lightWater.py
# Description : Use LEDbar Graph(10 LED)
# auther : www.freenove.com
# modification: 2019/12/28
########################################################################
import RPi.GPIO as GPIO
import time
ledPins = [11,12,13,15,16,18,22,3,5,24]
buttonpin = 32
def setup():
GPIO.setmode(GPIO.bOARD) # use PHYSICAL GPIO numbering
GPIO.setup(ledPins,GPIo.oUT) # set all ledPins to OUTPUT mode
GPIo.output(ledPins,GPIO.HIGH) # make all ledPins output HIGH level,turn off all led
GPIO.setup(buttonpin,GPIO.IN,pull_up_down=GPIO.PUD_Up)
def loop():
while True:
for pin in ledPins: # make led(on) move from left to right
GPIo.output(pin,GPIO.LOW)
time.sleep(0.1)
GPIo.output(pin,GPIO.HIGH)
for pin in ledPins[::-1]: # make led(on) move from right to left
GPIo.output(pin,GPIO.HIGH)
def display():
while True:
if GPIO.input(buttonpin) == GPIO.LOW:
loop()
else:
GPIo.output(ledPins,GPIO.HIGH)
def destroy():
GPIO.cleanup() # Release all GPIO
if __name__ == '__main__': # Program entrance
print ('Program is starTing...')
setup()
try:
display()
except KeyboardInterrupt: # Press ctrl-c to end the program.
destroy()
“将 RPi.GPIO 导入为 GPIO ModuleNotFoundError:没有名为‘RPi’的模块”
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)
以上是大佬教程为你收集整理的Python3 Raspberry Pi(ModuleNotFoundError:没有名为“RPi”的模块),带有代码和错误全部内容,希望文章能够帮你解决Python3 Raspberry Pi(ModuleNotFoundError:没有名为“RPi”的模块),带有代码和错误所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。