擅长:python、mysql、java
<p>在您的情况下,<code>aiocqhttp</code>安装在您的主目录中,当您通过<code>sudo</code>调用脚本时,<code>python3</code>将无法知道如何在您的主目录中进行搜索(因为运行该进程的是root)。您可以使用以下两种方法解决此问题:</p>
<p>方法1:</p>
<pre><code>sudo -H pip3 install -U aiocqhttp
</code></pre>
<p>在系统范围内安装此模块,以便每个用户都能找到它</p>
<p>方法2:</p>
<pre><code>sudo PYTHONPATH=/home/a495488027/.local/lib/python3.8/site-packages python3 mycode.py
</code></pre>
<p>将python模块搜索路径临时添加到<code>sudo</code>并运行代码。此时您不想在系统范围内安装软件包</p>
<hr/>
<p>回到你的问题上来</p>
<pre><code>sudo PYTHONPATH=/home/a495488027/.local/lib/python3.8/site-packages bash script.sh
</code></pre>
<p>我应该做这项工作</p>