Problem: I am a beginner in programming and I learned Python because of my scientific research. I wanted to run some python modules like numpy, sklearn, etc. (in machine learning) on ironpython, but I couldn’t find a good way…
Question: I thought of exporting an exe output from the python code and programming it in a way that I could interact with on ironpython. That means getting inpout and output.** Is this possible with subprocess? or Is there a better way?
Advertisement
Answer
Yes you can achieve this in Python shell by using subprocess. For input you have to add input at my_input_here in below codes.
You can store the output in p by following method:
p = subprocess.check_output("myfile.exe my_input_here", shell=True).strip()
or you can also use subprocess like this:
p = subprocess.Popen(['myfile.exe', 'my_input_here'],stdin=subprocess.PIPE,stdout=subprocess.PIPE,stderr=subprocess.PIPE)