brettmclean / pad4pi

Interrupt-based matrix keypad library for Raspberry Pi
GNU Lesser General Public License v3.0
51 stars 19 forks source link

doesn’t load for programs running at boot time #14

Closed CentralHarlemAnonymous closed 4 years ago

CentralHarlemAnonymous commented 4 years ago

I’m not sure whether this is a problem with the library or the installation script or something else, but I have a couple of python programs using pad4pi that I want to run at boot time.

The software works perfectly if run from the command line, whether launched from its own directory or any other. However if I try to run at launch by putting the script in rc.local, nothing happens and I log the following error:

Traceback (most recent call last):
  File "/home/pi/sound.py", line 4, in <module>
    from pad4pi import rpi_gpio
ImportError: No module named pad4pi

Why would the library be available from the command line but not at launch? Can this be fixed?

CaptClaude commented 4 years ago

I have several projects using pad4pi that load at boot time and run just fine, day in and day out. I suspect it has to do with where you installed the pad4pi library. I don't have access to any of those devices at the moment, so I can't check. It might also have something to do with how you are launching it at boot time.

CentralHarlemAnonymous commented 4 years ago

Some additional color: which python returns '/usr/bin/python’ and I have fully specified in rc.local that this is the python to use (/usr/bin/python /home/pi/sound.py &)

I installed with pip install pad4pi, and checking a moment ago it confirms that pad4pi in ./.local/lib/python2.7/site-packages (1.1.5)

Any guesses as to why this would not appear at boot?

problem now solved: pad4pi was not appearing in $Pythonpath. I added export PYTHONPATH=$PYTHONPATH:/home/pi/.local/lib/python2.7/site-packages to my rc.local file, before it ran my python code, and all was well.