I have a RPi 2 (running raspbian jessie with pixel) and just tried to install the GPIO module:
I have downloaded and installed from source. Then I issue commands:
pi@raspberry:python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
so then I tried using sudo:
pi@raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using pip:
pi@raspberry:sudo pip install RPi.GPIO
pi@raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using apt-get:
pi@raspberry:sudo apt-get update
pi@raspberry:sudo apt-get -y install python-rpi.gpio
pi@raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
It seems it has nothing to do with the install method, so I'm assuming it's something to do with either Raspbian Jessie + pixel or the current version of python-gpio is broken/incompatible.
Its strange because I am not importing "_GPIO", I am importing "GPIO", which indicates to me that my python syntax is not the culprit.
Could somebody please recommend what I should try next?
Also I searched this exact error on Google and got 1 result which was not helpful.
Thanks,
i think you have a dir called RPi in your current dir,so change your python file to another dir which doesn't have ,it works for me...hope it's helpful :)