I have a Mathematica script that I can run as a bash executable from Terminal. I want to run it from within Python and get the result out. This is the code I wanted to use:
proc = subprocess.Popen(["./solve.m", Mrefnorm, Mvert, Mcomp, Mangle],
stdout=subprocess.PIPE,stderr=subprocess.PIPE)
result, err = proc.communicate()
Unfortunately the result is an empty string. However, when I run this code, the result is printed to the terminal window as I would expect:
proc = subprocess.Popen(["./solve.m", Mrefnorm, Mvert, Mcomp, Mangle],
stdout=subprocess.sys.stdout,stderr=subprocess.sys.stdout)
I found this answer for someone with windows and it is the exact same problem I am having. Unfortunately his solution related to his firewall software sandboxing the processes. I already disabled mine to check if that would resolve it and it does not. I have tried everything that the commenters mentioned on his question with no success.
In summary, the Mathematica script runs in both cases (takes about 5 seconds for both) but when I use PIPE, I can't get at the output from the script.