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,3773 gold badges25 silver badges39 bronze badges
asked Jan 22, 2018 at 11:00
2
  • 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. Commented Jan 22, 2018 at 11:20
  • @EricClack by environment variable are you referring to the telepot module that it is saying it cannot find? Commented Jan 22, 2018 at 13:05

2 Answers 2

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.

answered Jan 22, 2018 at 15:51
2
  • Thanks, the sudo pip3 install telepot did it! Now I have some errors with my script connecting to online APIs but I'll give it some googling first Commented Jan 22, 2018 at 15:59
  • Good to hear, @Purdy; you can mark this as accepted if you're happy with it — that's our way of saying thanks here. If you're still having trouble, feel free to link to your new question. Commented Jan 22, 2018 at 16:01
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,8833 gold badges18 silver badges22 bronze badges
answered May 8, 2021 at 12:53

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.