Using Jupyter Notebooks - Looping and calling multiple os.system(cmd) doesn't properly terminate

I’ve copied the code directly into JupyterLab and it runs perfectly and confirmed the environments are constructed the same. After running os.system(cmd) or subprocess.run(cdm) results in a hung loop that doesn’t progress to next line.