Solved Run a pyFile(QApplication) from a button of another app
-
@Giakara please provide a minimal and reproducible example.
-
self.p.start("python3", ['/full/path/to/main.py'])
is the correct way to run a Python script as a subprocess under Linux, assuming
python3
is on your path (/usr/bin/python3
).Remember that all this does is starts the other process. It doesn't wait for it, it runs in the background. What is it that your Python script does so that you even know whether it has run, or run successfully, or not?
Look at the documentation for
QProcess
. Use the methods and signals to print out the status of the subprocess, capture any error and finished signals, and sometimes you need to capture standard output/error if an error message is sent there. -
@JonB OR
self.p.start(sys.executable, ['/full/path/to/main.py'])
-
@eyllanesc
Yes if you're coming from a Python script, which the OP is, I just meant generically like similar from, say, a C++ program. But indeed. -
@eyllanesc this solved my my problem thank you very much!
-
@Giakara
Out of interest, what does yourprint(sys.executable)
output? -
it opens the window that i create on the main.py which is not exactly qt widget it is a wrapinstance of qWidget and i don t know exactly who it works so i do this
-
@Giakara
Thanks, but that wasn't at all my question. I am interested in knowing what the value of yoursys.executable
Python variable is, since you saidself.p.start(sys.executable, ['/full/path/to/main.py'])
is required to work for you rather than using"python3"
, that's all. -
@JonB venv\Scripts\python.exe full path to python.exe
-
@Giakara
Wow! So you are on Windows and were trying to runpython3
as the executable! OK :)