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
2 Answers 2
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 withsudo pip install telepot
, then leave yourrc.local
unchanged.Switch to the
pi
user in rc.local by replacing the old script line inrc.local
withsudo -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.
-
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 firstPurdy– Purdy2018年01月22日 15:59:42 +00:00Commented 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.Aurora0001– Aurora00012018年01月22日 16:01:52 +00:00Commented Jan 22, 2018 at 16:01
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
export
from a regular shell and compare this with anexport
command in yourrc.local
(in the log file) you'll be able to see any difference, and you can fix this withexport VAR=...
in your rc.local file.