I'm trying to launch a C++ file using the python function "subprocess". I can begin the execution of the program, but it does not manage to read the data file I put in parameter.
However, when I lauch the C++ file directly with the same path to the same data the program works perfectly.
Do you have any ideas on why it does not work using a subprocess ?
The command line I'm using in my python file looks like this:
datafilePath="/home/*...*/dataFile.txt"
subprocess.run(["./programName", "-f "+datafilePath, (OtherOptionsWorkingFine) ], cwd="./pathToMyProgram")
I think you are adding the datafilePath argument wrongly. Try to add all args as separate list items instead of concatenating (some of) them together as a string.
eg
subprocess.run(["./programName", "-f", datafilePath, (OtherOptionsWorkingFine) ], cwd="./pathToMyProgram")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.