I have a simple python script
import boto3
print('I know you are installed')
I'm sure the boto3 module is installed
pip3 install boto3
If run via terminal
python3 test.py
I get the expected output
I know you are installed
If I run the same script via Upstart
description "test"
author "me"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
chdir /var/www/html/
script
exec nohup /usr/bin/python3 -u /var/www/html/test.py >
/var/www/html/test.log
end script
I get
tail: /var/www/html/test.log: file truncated
Traceback (most recent call last):
File "/var/www/html/test.py", line 1, in <module>
import boto3
ImportError: No module named 'boto3'
Why can't the boto3 module be found when running the script from Upstart?
I ended having to add the following to my script
sys.path.append("/home/ubuntu/.local/lib/python3.5/site-packages")
Seems as though when running python via Upstart, even though it was using 3.5 it wasn't looking in that site-packages directory