0

I am trying to get the rpi.gpio to work with Python 3.4 on Raspberry Pi 3. I have tried every command to install and when I am in the active idle terminal, it seems to load just fine. But when I run the script from the Pi terminal, I get this.

ImportError: No module name rpi.gpio

I'm using Raspbian. This makes no sense to me, but I can only assume it is user error. Everything works just fine in Python 2.7. I don't understand why I can't get it to work on 3.4.

4

Keep in mind that when programming, everything is case-sensitive. Based on the given error message, I can assume that your line of code says "import rpi.gpio", but due to the case-sensitivity, you must change it to "import RPi.GPIO"

  • everything is case-sensitive is a blanket statement which is not strictly true. "Python language is case-sensitive" would be better scoped IMO. – Dmitry Grigoryev Jan 23 '17 at 13:14
  • It's probably a case-sensitive thing - otherwise could be related to the python-version-specific version of the module. Also you should try gpiozero - a higher-level API for GPIO: gpiozero.readthedocs.io – ben_nuttall Jan 23 '17 at 13:16
0

The error that you are showing is due to case-sensitivity. The proper module name is 'RPi-GPIO'. However, in the case that that does not work you will need to install the RPi-GPIO library:

sudo apt-get install python-dev python-rpi.gpio

If using apt-get doesn't work you will need to install it via pip

sudo pip install RPi.GPIO

We have also seen that pip was not included with Python 3.4, in which you will have to install the dependencies: (I would suggest updating before doing so)

sudo apt-get update     
sudo apt-get install libssl-dev openssl

Then finally we can run pip to install RPi-GPIO

sudo pip install RPi.GPIO

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.