Is there any cute way for a python script to tell that it's missing python packages, and then import those? I could only think of some yucky approach like this. Basically you would read in the python file, check what modules were imported, then use pip list to check if those really existed or not. If they don't install them. The idea is below. It strikes me as really ugly. I bet python has a nicer way to do this, but haven't found anything.
P.S. I know this idea doesn't work 100% , but it's just an illustration of the best approach I could think of.
import os
import cv2
def boke():
with open('list.txt') as file:
lines = file.readlines()
return lines
os.system("pip3 list > list.txt")
l = boke()
if "cv2" in l == false:
os.system("pip3 install cv2")