QProcess.start() is deprecated, what are the alternatives?

Update how you launch subprocesses with arguments in PyQt5 & PySide2
Heads up! You've already completed this tutorial.

A reader wrote in with an interesting problem when trying to launch an external script using QProcess in PyQt5/PySide2.

When trying to launch another script in a sub-process I got the error: QProcess.start(const QString & command, QFlags<QIODevice::OpenModeFlag> mode) is deprecated. Having checked the documentation it mentioned .start() was obsolete but did not suggest replacement. Do you have any suggestions.

Why is QProcess.start() showing a deprecation warning?

The confusion here comes from the .start() method being overloaded — it can be called with different signatures (collections of arguments). The .start() method itself is not removed or deprecated, just the specific signature where .start() is called with a single string containing the program and arguments together.

Deprecated members for QProcess List of deprecated methods for QProcess: note that only this signature for .start is deprecated

How to fix the deprecated QProcess.start() call

In the new API you need to set the program and arguments separately, with the latter passed as a list of strings — one item per argument. This approach is less prone to errors since it's explicit what each value you're passing actually represents.

Old approach (deprecated single-string signature)

python
p = QProcess()
p.start("python dummy_script.py")

New approach using setProgram() and setArguments()

python
p = QProcess()
p.setProgram("python")
p.setArguments(['dummy_script.py'])
p.start()

By using setProgram() and setArguments() separately, you avoid the deprecated single-string signature and make your subprocess calls clearer and more maintainable.

Alternative: pass program and arguments directly to start()

You can also pass the program and arguments as separate parameters directly to .start(), which is the non-deprecated overload:

python
p = QProcess()
p.start("python", ['dummy_script.py'])

This achieves the same result as the setProgram()/setArguments() approach, but in a single line. Both methods are valid — choose whichever is clearest for your use case.

Summary

The QProcess.start() method is not fully deprecated in PyQt5 or PySide2. Only the single-string overload that combines the program name and arguments into one string is deprecated. To fix the warning, separate the program from its arguments by using either setProgram() and setArguments() before calling .start(), or by passing them as distinct parameters to .start("python", ['dummy_script.py']).

Over 15,000 developers have bought Create GUI Applications with Python & Qt!
Create GUI Applications with Python & Qt5
Get the book

Downloadable ebook (PDF, ePub) & Complete Source code

[[ discount.discount_pc ]]% OFF for the next [[ discount.duration ]] [[discount.description ]] with the code [[ discount.coupon_code ]]

Purchasing Power Parity

Developers in [[ country ]] get [[ discount.discount_pc ]]% OFF on all books & courses with code [[ discount.coupon_code ]]

The book has been updated with this new style API.

PyQt/PySide Office Hours 1:1 with Martin Fitzpatrick — Save yourself time and frustration. Get one on one help with your projects. Bring issues, bugs and questions about usability to architecture and maintainability, and leave with solutions.

60 mins ($195)

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

QProcess.start() is deprecated, what are the alternatives? was written by Martin Fitzpatrick.

Martin Fitzpatrick is the creator of Python GUIs, and has been developing Python/Qt applications for the past 12+ years. He has written a number of popular Python books and provides Python software development & consulting for teams and startups.