所以我试图在 1 个脚本中一起运行 3 个独立的不和谐机器人。
start.sh 脚本如下所示;
node spamprevention/index.js > logs/spamprevention.log 2>&1 &
node reportbot/index.js > logs/reportbot.log 2>&1 &
python main.py
while :; do
sleep 5
done
在该目录中,&文件夹以及和文件所在pi@tradehubrpi:~/discordbots/trade-hub-secret-agent
的位置。我在终端中输入来启动这个脚本。spamprevention
reportbot
start.sh
main.py
bash start.sh
这是日志;
pi@tradehubrpi:~/discordbots/trade-hub-secret-agent $ bash start.sh
start.sh: line 1: logs/spamprevention.log: Permission denied
start.sh: line 2: logs/reportbot.log: Permission denied
Traceback (most recent call last):
File "main.py", line 13, in <module>
from discord import * # import library
File "/home/pi/discordbots/trade-hub-secret-agent/discord/__init__.py", line 21, in <module>
from typing import NamedTuple, Literal
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)
^C
pi@tradehubrpi:~/discordbots/trade-hub-secret-agent $ sudo bash start.sh
Traceback (most recent call last):
File "main.py", line 10, in <module>
import aiohttp
ModuleNotFoundError: No module named 'aiohttp'
2 个 javascript 机器人运行良好,但对于 python 机器人,我得到了ModuleNotFoundError
.但是当我python main.py
在终端运行时它工作正常。
正如您现在所知,我不是开发人员。有一个简单的解决办法吗? (在 Raspberry Pi 4 上运行这些)
编辑;没有运行日志python main.py
,这意味着它运行正确,日志将显示是否存在错误或不和谐的某种类型的操作。
运行时sudo python main.py
返回此;
pi@tradehubrpi:~/discordbots/trade-hub-secret-agent $ sudo python main.py
Traceback (most recent call last):
File "main.py", line 13, in <module>
from discord import * # import library
File "/home/pi/discordbots/trade-hub-secret-agent/discord/__init__.py", line 21, in <module>
from typing import NamedTuple, Literal
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)