PDA

View Full Version : Trying to launch a program through another one.



robgeek
13th January 2016, 03:14
Me and my sister made a program using Qt Framework in c++ and when i click in a button this program should launch another program(web crawler) made in python(she preferred to do using this language). The problem is when i click on that button i get the following error message:


c:\Python34\python.exe is not recognized as an internal or external command, operable program or batch file.

How we call it in my c++ code.

void Historic::on_pushButton_clicked( ) {
system("c:\Python34\python.exe d:\Programming\Python\Pycharm\test.py");
}

Python code just to test:

fw = open(r'd:\Programming\Python\Pycharm\test.txt', 'w')
fw.write("working fine")
fw.close( )

What is wrong? How can we fix it? We are using Windows 7-64bit.

d_stranz
13th January 2016, 05:15
For one thing, in C++ you need to escape backslashes in strings: "C:\\Python34\\python.exe" as well as in the argument string.

See the answer to your other post to learn how to do this the Qt way.