If you run the program through IDE (PyCharm), then everything works fine.
If you run the / bat-file through the console, then there simply is no output, I suspect that you need to run the script correctly somehow.

Code snippet

def run_command(command): filename = 'test.log' with io.open(filename, 'wb') as writer, io.open(filename, 'rb', 1) as reader: process = subprocess.Popen(command, stdout=writer) while process.poll() is None: time.sleep(0.5) 

This function is called via a thread:

 class MyThread(Thread): STOP = False def __init__(self, name): Thread.__init__(self) self.name = name def run(self): global OUTPUT, STOP print(235) #p = subprocess.Popen("python main.py", stdout=subprocess.PIPE, bufsize=2) #for line in iter(p.stdout.readline, b''): if(self.name == "run"): run_command("./venv/Scripts/python main.py") if(self.name == "stop"): """Nothing...""" 

And the startup file itself:

 /venv/Scripts/python interface.py 

Already tried a bunch of options, with a record in the log file, and a bunch of examples of realtime output, I stopped at the first one. Again, I repeat, the code works successfully through the IDE, but refuses to work through the bat file. No errors, just no output (

  • the minimum change, I suspect, is to use the full path instead of the relative¶ In general, the code can be simplified noticeably: no while poll() needed, the Thread subclass creates not clear why. py and import the module and call the function from it. If you want to run exactly like an external command, the Python code, then describe in detail what it means "works great": do you want to save the output of the external command to a file, so as not to block the main thread? (All you need is a couple of calls. - jfs

0