ModuleNotFoundError: No module named 'twilio' (when running systemctl)

ぃ、小莉子 提交于 2019-12-13 04:26:15

问题


I can run my python script using

python3 detector.py

however, when I try to run it with systemctl, I get...

Aug 07 04:03:44 raspberrypi systemd[1]: Started Detector.
Aug 07 04:03:45 raspberrypi python3[964]: Traceback (most recent call last):
Aug 07 04:03:45 raspberrypi python3[964]:   File "/home/pi/detector.py", line 4, in <module>
Aug 07 04:03:45 raspberrypi python3[964]:     from twilio.rest import Client
Aug 07 04:03:45 raspberrypi python3[964]: ModuleNotFoundError: No module named 'twilio'
Aug 07 04:03:45 raspberrypi systemd[1]: detector.service: Main process exited, code=exited, status=1/FAILURE
Aug 07 04:03:45 raspberrypi systemd[1]: detector.service: Failed with result 'exit-code'.

Why would I be able to see the module when I run it manually, but not through the service?

/lib/systemd/system/detector.service

[Unit]
Description=Detector
After=multi-user.target

[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/detector.py > /home/pi/detector.log

[Install]
WantedBy=multi-user.target

When I am in my terminal and I run:

which python3, I get /usr/bin/python3

来源:https://stackoverflow.com/questions/57386467/modulenotfounderror-no-module-named-twilio-when-running-systemctl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!