在Python 3.6上使用RPi.GPIO [英] Use RPi.GPIO with Python 3.6
本文介绍了在Python 3.6上使用RPi.GPIO的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试将RPi.GPIO与Python 3.6结合使用. 我安装了RPi.GPIO,它可用于Python 3.4,但不适用于Python 3.6 我收到此错误:
I try to use RPi.GPIO with Python 3.6. I installed RPi.GPIO and it's working with Python 3.4, but not with Python 3.6 I get this Error:
ModuleNotFoundError:没有名为"RPi"的模块
ModuleNotFoundError: No module named 'RPi'
我将模块导入到我的脚本中,如下所示:
I immport the module in my script like this:
import RPi.GPIO as GPIO
推荐答案
将此行添加到* .py文件的顶部:
Add this line to the top of your *.py file:
#!/usr/bin/env python3.6
在您的shell中运行以下命令:
Run these commands in your shell:
sudo python3.6 -m pip install --upgrade pip setuptools wheel
sudo python3.6 -m pip install RPi.GPIO
这应该可以解决问题.
这样,您将为正确的python版本安装RPi.GPIO.在这种情况下,为3.6.x.
This should fix the Problem.
By this you will install RPi.GPIO for the right python version. In this case 3.6.x.
这篇关于在Python 3.6上使用RPi.GPIO的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文