11

So I've tested that my script does attempt to run and I'm recording the error message of

Traceback (most recent call last):
    File "/home/pi/steamFriendStatus_v0.3.py", line 6, in <module>
       import telepot
ImportError: No module named 'telepot'

This module works fine running the script from terminal/IDLE/Thonny and I'm declaring to use Python 3 / full Python 3 directory in the rc.local command

My rc.local file is below:

exec > /tmp/rc-local.log 2>&1

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi


/usr/bin/python3 /home/pi/steamFriendStatus_v0.3.py

exit 0
Aurora0001
  • 6,308
  • 3
  • 23
  • 38
Purdy
  • 113
  • 1
  • 1
  • 4
  • It might be the environment variables available to the script. If you run export from a regular shell and compare this with an export command in your rc.local (in the log file) you'll be able to see any difference, and you can fix this with export VAR=... in your rc.local file. – Eric Clack Jan 22 '18 at 11:20
  • @EricClack by environment variable are you referring to the telepot module that it is saying it cannot find? – Purdy Jan 22 '18 at 13:05

2 Answers2

16

It's worth noting that rc.local is run by root, rather than the pi user which you are likely using at your terminal. It seems likely that your installation for the telepot module is installed only for the pi user, and hence when root runs the script, the module cannot be found. If this is the case, you have two options:

  • Install the telepot module globally for all users with sudo pip install telepot, then leave your rc.local unchanged.

  • Switch to the pi user in rc.local by replacing the old script line inrc.local with sudo -H -u pi /usr/bin/python3 /home/pi/steamFriendStatus_v0.3.py.

Either of the above should ensure that the telepot module is available as required.

Aurora0001
  • 6,308
  • 3
  • 23
  • 38
0

I have experienced same problem with dill module.

If you already installed teleport as your pi user, and if sudo pip or pip3 install gives errors try:

sudo -H pip install teleport

this way, you can install it also for root, and it will start at rc.local

MatsK
  • 2,791
  • 3
  • 16
  • 20