I am trying to run util.py from script
/bin/sh: ./util.py: No such file or directory
./util.py in a terminal means "Look in the current working directory for a file named util.py and run it." The working directory is the directory from where you run the command. This means that your python script cannot see util.py if you run it from a different directory.
If you are sure that file1.py and util.py always lie in the same directory, you could use
os.path.dirname to prefix it with the directory of file1.py:
#!/usr/bin/env python import os import subprocess current_dir = os.path.dirname(__file__) filename = os.path.join(current_dir, "util.py") out = subprocess.Popen([filename], shell=True) print("done")