I'm computing neural networks with several .py files in spyder. I could sequencely execute them in spyder. However, the console do not show any thing like single file execution. For example, this is the single file ouput:
In [1]: runfile('NN.py', wdir='D:/test')
[1/200] losses:... loss_D:... loss_G:...
...
This is the sequence file:
[1]runfile('D:Sequential_execution_test.py', wdir='D:/test')
There is only blank in console of spyder.
Here are the sequence codes:
import os
import sys
import subprocess
from subprocess import Popen, PIPE, CalledProcessError
script_paths = [r'D:\code1.py', r'D:\code2.py']
for script in script_paths:
os.chdir(os.path.dirname(script))
with Popen(["python", script], stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
print(line, end='') # process line here
sys.stdout.flush()
By the way, the code could work well. Only the output is not shown in console of spyder. Is there any way to shown subprocess output in spyder console? Thanks for any help. PS: I have uncheked "Hide command line output windows generated by the subprocess module." in preference.