![在 virtualenv 中将 Python 脚本作为服务运行](https://linux22.com/image/168583/%E5%9C%A8%20virtualenv%20%E4%B8%AD%E5%B0%86%20Python%20%E8%84%9A%E6%9C%AC%E4%BD%9C%E4%B8%BA%E6%9C%8D%E5%8A%A1%E8%BF%90%E8%A1%8C.png)
我想运行一个 python 脚本,它使用 virtualenv 作为服务。我已经研究了一些,但找不到可行的解决方案。我已将虚拟环境 python 的路径放在 python 的第一行。该服务如下所示:
[Unit]
Description=Telegram Bot Service
After=multi-user.target
[email protected]
[Service]
Type=simple
ExecStart=/usr/bin/python3.7 /home/pi/github/python/telegrambot.py
StandardInput=tty-force
[Install]
WantedBy=multi-user.target
错误:
● telegrambot.service - Telegram Bot Service
Loaded: loaded (/lib/systemd/system/telegrambot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Tue 2020-03-03 15:04:11 GMT; 3s ago
Process: 15090 ExecStart=/usr/bin/python3.7 /home/pi/github/python/telegrambot.py (code=ex
Main PID: 15090 (code=exited, status=1/FAILURE)
Mar 03 15:04:11 raspberrypi systemd[1]: Started Telegram Bot Service.
Mar 03 15:04:11 raspberrypi systemd[1]: telegrambot.service: Main process exited, code=exite
Mar 03 15:04:11 raspberrypi systemd[1]: telegrambot.service: Failed with result 'exit-code'.
感谢您提前提供任何帮助!