"""Run a script in headless Blender at below-normal priority (the user works on this PC): python run_blender.py script.py [blend] [-- args]""" import subprocess, sys, os BL = r'E:\Steam\steamapps\common\Blender\blender.exe' a = sys.argv[1:] script = a[0]; rest = a[1:] blend = [] if rest and rest[0].endswith('.blend'): blend = [rest[0]]; rest = rest[1:] cmd = [BL, '-b'] + blend + ['--factory-startup', '-t', '0', '--python', script] + rest p = subprocess.Popen(cmd, creationflags=subprocess.BELOW_NORMAL_PRIORITY_CLASS, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, encoding='utf-8', errors='replace') out = [] for line in p.stdout: out.append(line) p.wait() txt = ''.join(out) keep = [l for l in txt.splitlines() if not l.startswith(('Read prefs', 'Blender quit', 'Warning: Unable'))] print('\n'.join(keep[-80:])) sys.exit(p.returncode)