Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

python 3.x - Raspberry Pi, and linux systemd, and .system files

I'm trying to to run a script when my raspberry pi reboots, but its giving me this error. the script works when I run it in terminal, but it doesn't run when I use systemd

● Refridgerator.service - The refridgerator thing

   Loaded: loaded (/etc/systemd/system/Refridgerator.service; enabled; vendor preset: enabled)

   Active: failed (Result: exit-code) since Tue 2021-01-19 17:20:34 EST; 11min ago

  Process: 777 ExecStart=/usr/bin/python3 /home/pi/Refridgerator.py (code=exited, status=1/FAILURE)

 Main PID: 777 (code=exited, status=1/FAILURE)

Jan 19 17:20:33 raspberrypi systemd[1]: Started The refridgerator thing.

Jan 19 17:20:33 raspberrypi python3[777]: Traceback (most recent call last):

Jan 19 17:20:33 raspberrypi python3[777]:   File "/home/pi/Refridgerator.py", line 3, in <module>

Jan 19 17:20:33 raspberrypi python3[777]:     from pydub import AudioSegment

Jan 19 17:20:33 raspberrypi python3[777]: ModuleNotFoundError: No module named 'pydub'

Jan 19 17:20:34 raspberrypi systemd[1]: Refridgerator.service: Main process exited, code=exited, status=1/FAILURE

Jan 19 17:20:34 raspberrypi systemd[1]: Refridgerator.service: Failed with result 'exit-code'.
[Unit] 
Description=The refridgerator thing 
After=multi-user.target 
[Service] 
Type=simple 
ExecStart=/usr/bin/python3 /home/pi/Refridgerator.py 
Restart=on-abort 
[Install] 
WantedBy=multi-user.target

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I solved it by reinstalling pydub with sudo pip instead of just pip

sudo pip3 install pydub

or

sudo pip install pydub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...