Search code examples
python-3.xsubprocessexepopenlaunch

Popen doesn't run my exe


(Python 3)

I'm trying to use popen in a little script to run an executable

The executable is at : https://github.com/Gorov/FCM_nips_workshop

I'm on windows and by modifying a little the github README command I can run easily the program using

RE_FCT ../data/SemEval.train.fea.sst ../data/SemEval.test.fea.sst predict.fea.fullnerpair.onlyne.txt ../data/vectors.nyt2011.cbow.semeval.filtered 5 0.005

The exe is RE_FCT and all the following text is just arguments

So using a terminal it works just fine and display informations while runing

But when I try to make it run using my little python script, it does nothing. Actually something seems runing but it never ends and doesn't display anything

Here's my code

import subprocess


command = ['RE_FCT', '../data/SemEval.train.fea.sst', '../data/SemEval.test.fea.sst ', 'predict.fea.fullnerpair.onlyne.txt', '../data/vectors.nyt2011.cbow.semeval.filtered', '5', '0.005']
process = subprocess.Popen(test, cwd="fcm", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process.wait()

print() #sometimes it helps

Note that I'm already running another exe with similar code and it works Thanks in advance


Solution

  • Just solved it

    I don't know exactly what is going on but the problem is with the process.wait(), I just deleted it and replaced the Popen function with the run fonction and it works

    The difference between those two is that popen allows the script to run immediatly after you call it by creating a process, while using run you have to wait for the task to end