# python 自动安装缺少依赖 import subprocess, os while True: out = subprocess.getoutput("sudo python3 server.py") keyword = "No module named '" if keyword in out: lib = out[out.index(keyword) + len(keyword):-1] os.system(f"sudo pip3 install {lib}") else: break