How to run external QT program from PyQT5 on MacOS
-
Does it only happen with Dolphin ?
By the way, why Dolphin on macOS rather than Finder ? -
Well Dolphin is the only .app I am trying to open with my program, so I wouldn't know if this happens with other programs.
What do you mean by macOS rather than Finder?
-
Well Dolphin is the only .app I am trying to open with my program, so I wouldn't know if this happens with other programs.
What do you mean by macOS rather than Finder?
@Benjamin-Halko said in How to run external QT program from PyQT5 on MacOS:
What do you mean by macOS rather than Finder?
The file manager on MacOS is called Finder. There is no Dolphin unless you install it.
-
@jsulm Yeah finder is installed. By Finder rather than MacOS do you mean telling finder to open Dolphin Emulator rather than just tell MacOS to open it?
Oh and Dolphin works just fine when running it from Finder normally, it is just when I launch it using
subprocess.Popen
that is the trouble. -
From the looks of it, we are talking about very different software.
"Dolphin" is known to be the KDE file manager. So from the looks of it you are trying to start something very different. Can you give more details about what it is ? And what exactly you are trying to do with your application ?
-
From the looks of it, we are talking about very different software.
"Dolphin" is known to be the KDE file manager. So from the looks of it you are trying to start something very different. Can you give more details about what it is ? And what exactly you are trying to do with your application ?
@SGaist I am wanting to open the Dolphin Emulator from my app as well as tell it to load a game using the -e argument that it accepts. However since Dolphin is also a QT program when trying to run it using subprocess, it tries loading both sets of libraries (from my app and Dolphin)
-
What if you use the QProcess::startDetached method ?
-
What if you use the QProcess::startDetached method ?
@SGaist Ok so I tried and nothing happened! But then I tried using the executable located in
/Contents/MacOS/Dolphin
and it gave me this:objc[2357]: Class QMacAutoReleasePoolTracker is implemented in both /Users/benjamin/Desktop/Dolphin.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore (0x10b53a9f8) and /private/var/folders/50/g29zbzlx4fb85zh8kk4g6gm40000gn/T/_MEIYRjNbS/QtCore (0x10efe8198). One of the two will be used. Which one is undefined. objc[2357]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /Users/benjamin/Desktop/Dolphin.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore (0x10b53aa70) and /private/var/folders/50/g29zbzlx4fb85zh8kk4g6gm40000gn/T/_MEIYRjNbS/QtCore (0x10efe8210). One of the two will be used. Which one is undefined. objc[2357]: Class KeyValueObserver is implemented in both /Users/benjamin/Desktop/Dolphin.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore (0x10b53aa98) and /private/var/folders/50/g29zbzlx4fb85zh8kk4g6gm40000gn/T/_MEIYRjNbS/QtCore (0x10efe8238). One of the two will be used. Which one is undefined. objc[2357]: Class RunLoopModeTracker is implemented in both /Users/benjamin/Desktop/Dolphin.app/Contents/Frameworks/QtCore.framework/Versions/5/QtCore (0x10b53aae8) and /private/var/folders/50/g29zbzlx4fb85zh8kk4g6gm40000gn/T/_MEIYRjNbS/QtCore (0x10efe8288). One of the two will be used. Which one is undefined. QObject::moveToThread: Current thread (0x7faab1e065c0) is not the object's thread (0x7faab1c17ed0). Cannot move to target thread (0x7faab1e065c0) You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded. qt.qpa.plugin: Could not load the Qt platform plugin "cocoa" in "" even though it was found. This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: cocoa, minimal, offscreen, webgl.
This was the code I used:
launch = QProcess() launch.startDetached(dolphinPath+"/Contents/MacOS/Dolphin")
-
What if you use the QProcess::startDetached method ?
@SGaist Oh by the way, this issue only occurs when the program is packaged with pyinstaller, running it regularly works just fine.
-
What exactly are you packaging ?
-
Here is my project folder. Here is the actual run dolphin function. Hope that helps.
-
Did you try to use Popen with
shell=True
? -
@SGaist It gave the same error
LSOpenURLsWithRole() failed with error -10810 for the file /Users/benjamin/Desktop/Dolphin.app.
Oh and I tried starting the .app not executable in
/Contents/MacOS/
-
Which version of Qt are your application and Dolphin using ?
-
@SGaist I am using PyQt5 (I think version 5.12.2) And I have been informed that Dolphin uses 5.15.0 (C++). Although it seems that Dolphin uses this custom version ...maybe???
-
You should try with both using the same version of Qt.
-
My bad I was using PyQt5 version 5.15.5, but I will still try using Dolphins version.
-
@SGaist Ok so I update PyQt5 and I used
['open', '/Users/benjamin/Desktop/Dolphin.app/Contents/MacOS/Dolphin'],shell=False
and it worked!
But then when I went to use['open', '/Users/benjamin/Desktop/Dolphin.app/Contents/MacOS/Dolphin', '--args', '-e', gamePath],shell=False
to try to load a game, it gave me theopen
command usage dialog. Is there something wrong with using--args
?
Also I tried things like opening with just/Users/benjamin/Desktop/Dolphin.app
or usingshell=True
but they also didn't work...I wonder if the arguments for Dolphin only work when running from the Dolphin.app and not the /Contents.... one.
Took a look and yep, the /Contents one doesn't support arguments... -
@SGaist Ok so I update PyQt5 and I used
['open', '/Users/benjamin/Desktop/Dolphin.app/Contents/MacOS/Dolphin'],shell=False
and it worked!
But then when I went to use['open', '/Users/benjamin/Desktop/Dolphin.app/Contents/MacOS/Dolphin', '--args', '-e', gamePath],shell=False
to try to load a game, it gave me theopen
command usage dialog. Is there something wrong with using--args
?
Also I tried things like opening with just/Users/benjamin/Desktop/Dolphin.app
or usingshell=True
but they also didn't work...I wonder if the arguments for Dolphin only work when running from the Dolphin.app and not the /Contents.... one.
Took a look and yep, the /Contents one doesn't support arguments...@Benjamin-Halko said in How to run external QT program from PyQT5 on MacOS:
Is there something wrong with using --args?
I don't know.
What exactly does "command usage dialog" tell you? You're probably using --args wrongly. -
@Benjamin-Halko said in How to run external QT program from PyQT5 on MacOS:
Is there something wrong with using --args?
I don't know.
What exactly does "command usage dialog" tell you? You're probably using --args wrongly.@jsulm It is just what it gives you when you just type
open
.Also, when launching the .app from Python, Dolphin starts then immediately crashes with this error message using Apples Crash Message Screen Thing: https://pastebin.com/NqBK0YvQ (It also shows
LSOpenURLsWithRole() failed with error -10810 for the file /Users/benjamin/Desktop/Dolphin.app.
in the terminal window)