I have same issue.I checked some documents and I found the following solution: add a time.sleep after os.startfile.
import os
import sys
import time
os.startfile(r"D:/DEV/Python-Diverses/os/testb.png", "print")
time.sleep(5)
It works for me. Maybe it works for you too.
P.S I got this solution from the following page: https://www.geeksforgeeks.org/how-to-print-all-files-within-a-directory-using-python/