Importing GPIO into python service code

RPI3/OSMC/HDD

I know this specific GPIO topic has been posted here in the past. However, this particular twist has me really confused :frowning:

I’m trying to set up a Python service (to handle a front panel push button reboot function…but that’s not the issue).

I’ve used this Python routine before and it functioned very well. On a “new” (whole other story :frowning: system I attempted to implement it again.

Firstly, I couldn’t get RPi.GPIO to install. I finally figured that out after a million different directions :frowning: Now if I do a “pip list” RPi.GPIO shows up as the latest version (-0.7.0). Good so far (I think).

In the push button code there is a line to “import RPi.GPIO as GPIO”. However, I keep getting the message:

“ImportError: No module named RPi.GPIO”

Doesn’t make any sense. Could this have something to do with permissions? Something else?

Anyone offer some insight and (yet some more :slight_smile: direction to help me get past this?

Appreciate the help. Thx and cheers…

Check python version and packages

Thx for the response Sam.

I’m running Python 2.7.13. Firstly, does that mean RPi.GPIO-0.7.0 isn’t backwards compatible?

If I do a “pip -v” I get

pip 9.0.1 from /usr/lib/python2.7/dist-packages

a “pip check” produces

No broken requirements found.

and a “pip list” shows

chardet (2.3.0)
dnspython (1.15.0)
pexpect (4.2.1)
Pillow (4.0.0)
pip (9.0.1)
ptyprocess (0.5.1)
pycrypto (2.6.1)
pygobject (3.22.0)
python-apt (1.4.0b3)
requests (2.12.4)
RPi.GPIO (0.7.0)
setuptools (33.1.1)
six (1.10.0)
Unidecode (0.4.19)
urllib3 (1.19.1)
wheel (0.33.6)

Any of this look suspect?

Appreciate the help…

Not sure. Setting this all up in a virtualenv is probably the best way

virtualenv? I did see some postings abt that. That would be something new and different (and odd :frowning: I’ve had this same py code running just fine under OSMC on another system that I put together abt 2 yrs. ago.

Has something changed with Debian since then (I figure that would be where this “issue” lies)? Or may be OSMC?

I’ll look closer at the virtualenv and see how that might help.

Thx and cheers…

I’m not sure what the issue would be here. If you installed via Pip I believe there is an option to install globally or just for a user. That may be your problem

Sam,

As usual, I appreciate the support. That solved it.

I reinstalled rpi.gpio using “sudo pip” and now it seems to work as expected (at least, the service started without any errors…yay!!! :slight_smile: Still need to confirm the function works…

Thanks, yet again, for your stellar support…cheers…