Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use RPi.GPIO with 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: No module named 'RPi'

I immport the module in my script like this:

import RPi.GPIO as GPIO
like image 954
no0by5 Avatar asked Mar 10 '17 15:03

no0by5


People also ask

Which Python library is used for GPIO?

If you code in Python, the RPi. GPIO Python library (included with Raspbian) lets you configure, read, and write to GPIO pins.

Is RPi GPIO installed by default?

GPIO Zero is installed by default in the Raspberry Pi OS desktop image, and the Raspberry Pi Desktop image for PC/Mac, both available from raspberrypi.org.


1 Answers

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.

like image 131
Rulle Avatar answered Oct 02 '22 19:10

Rulle