PYTHONPATH cannot find GPIO modules during import


#1

GPG’rs,

I have installed and successfully run the Python stuff on my GPG.
Also have created motion code using gopigo.py library modules.

Now, I am adding google speech rec and I have a new directory hierarchy which is not in the ~/gopigo path anymore. It is in ~/Awareness/

I run : from gopigo import *
and I see that it cannot import RPi.GPIO as GPIO
ImportError: No module named RPi.GPIO

It doesn’t fail when importing gopigo because I have an explicit PYTHONPATH value for that directory which sees that module.
When it goes through gopigo.py, it sees the GPIO stuff and cannot resolve it.
How can I set the dependencies up so all of the previously installed GPG stuff can be resolved?

I thought I could put another directory on the PYTHONPATH but I cannot find where the GPIO stuff lives.

Can you help? This is a project blocker for me.

Thanks


#2

Hi @salvideoguy,

It looks like installing the RPi.GPIO package using apt command, would help resolving this problem.

The apt keeps a list of packages that it can install in its cache (or repository). This cache has information on where the software is located. So when you say sudo apt-get install <package>, it checks its repository for the packages name. If the package is available in the list, it then proceeds to locate, download and install the software and all the required dependencies.

To install RPi.GPIO package system wide you can follow the instructions given here.

-Please let us know if this helps
Shoban