My ultimate goal is to run a Python script (the code need to call some subprocess) without terminal.
I tried with python launcher on Mac. The code works correctly when the "Run in a Terminal window" is checked.
(Notice that the shell=False
is default here.) However, it won't run the subprocess correctly when I uncheck that option.
I also tried to run in with Mac OS automator (Run Shell Script) — negative too.
Here is a small sample code.
import subprocess
with open("record","w") as f:
subprocess.call(["which","ipython"], stdout = f) # this line fails
subprocess.call(["open","."]) # this line always works
If I run from terminal, it creates a record file, which shows the ipython path. However when I run it from automator or python launcher without terminal window, it creates an empty file.