Use RPi.GPIO with Python 3.6

帅比萌擦擦* 提交于 2019-12-10 04:01:56

问题


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: No module named 'RPi'

I immport the module in my script like this:

import RPi.GPIO as GPIO

回答1:


Add this line to the top of your *.py file:

#!/usr/bin/env python3.6

Run these commands in your shell:

sudo python3.6 -m pip install --upgrade pip setuptools wheel
sudo python3.6 -m pip install RPi.GPIO

This should fix the Problem.
By this you will install RPi.GPIO for the right python version. In this case 3.6.x.



来源:https://stackoverflow.com/questions/42721664/use-rpi-gpio-with-python-3-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!