QProcess can launch programs but not python (command line)
The following code is failing to launch the python command line.
QProcess *myProcess = new QProcess(this); myProcess->start("\"C:\\Program Files\\Python27\\python.exe\"");
If I replace python27 with (for example)
notepad opens. Why is my program able to launch notepad but not Python Command Line?
I tried using startDetached() but that didn't make a difference.
QProcess::Error() gives me error 5: unknown error.
[edit koahnig: code tags added]
You should use codetags (right button above the input pane) for all your code snippets. Otherwise your code lines are hard to read.
qDebug() << QFile::exists("\"C:\\Program Files\\Python27\\python.exe\"");print? (I'm not taking the piss, I promise)
@VRonin it prints false. so that means that my the python.exe file doesn't exist, correct? Is there another explanation for this other than that I might have errors in my filepath? Because I cant see where it could be wrong.
@VRonin I maneged to fix it so that qDebug << exists() now returns true. Python is still not launching though.
What are you expecting when calling python like that ?
@SGaist I'm expecting the python command line to launch.
@SGaist is it wrong to expect the command line to actually open as a window? I've just noticed that I can open most applications except command lines. (When I try to launch cmd.exe, git-cmd.exe, python.exe nothing happens while I can open e.g. chrome.exe, git-bash.exe, notepad.exe)
is it wrong to expect the command line to actually open as a window
Yes, it is. Command line tools do not have any windows - they run in a shell/terminal (terminal has a window). On Windows you can try pythonw.exe instead of python.exe. Or you start cmd.exe and pass the path to Python executable with -c as parameter to cmd.exe