Different file explorer dependent on how application is started.
-
This might be partially a linux question. But my pyqt6 application has a different file explorer dependent on how the program is run. When running it from within PyCharm I get the following looking screen:
I think this is the normal (linux mint) file explorer that I am used to.However when executing from normal terminal, or from a .desktop shortcut. I get a very different file explorer window.
Which seems to be more of a pyQT style explorer.
I checked that the python that is ran is identical (print(sys.executable) is the same path). The only env variable set in PyCharm for execution is "PYTHONUNBUFFERED=1" which shouldnt cause this difference.
Does anyone know what settings I am missing and what might be causing this difference?
Kind regards,
-
@Dwarrel said in Different file explorer dependent on how application is started.:
a different file explorer
What is this in the context of Qt code? Do you mean these screenshots are from using Qt's
QFileDialog
class (for picking a file to open or save)? -
@SGaist said in Different file explorer dependent on how application is started.:
Hi,
In addition to what @JonB asked, you should start your script with the QT_DEBUG_PLUGINS environment variable set to 1 to check which plugins are getting loaded. You might have a different style for exemple.
Thank you this was a good suggestion. I compared the output of the two and there was one difference namely.
From terminal (where it goes wrong) qt.core.library: "/home/dwarrel/anaconda3/envs/sweet-potato/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so" cannot load: Cannot load library /home/dwarrel/anaconda3/envs/sweet-potato/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so: /home/dwarrel/anaconda3/envs/sweet-potato/bin/../lib/libharfbuzz.so.0: undefined symbol: FT_Get_Transform qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "/home/dwarrel/anaconda3/envs/sweet-potato/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so" : "Cannot load library /home/dwarrel/anaconda3/envs/sweet-potato/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so: /home/dwarrel/anaconda3/envs/sweet-potato/bin/../lib/libharfbuzz.so.0: undefined symbol: FT_Get_Transform" from pycharm (What I want) qt.core.library: "/home/dwarrel/anaconda3/envs/sweet-potato/lib/python3.12/site-packages/PyQt6/Qt6/plugins/platformthemes/libqgtk3.so" loaded library
I tried googling this but havent found anything related to this.
@JonB said in Different file explorer dependent on how application is started.:
What is this in the context of Qt code? Do you mean these screenshots are from using Qt's
QFileDialog
class (for picking a file to open or save)?Yes sorry, so this happens when opening a QFileDialog().
file_dialog = QFileDialog(self) file_dialog.setDirectory(qt_settings.setValue("file_dialog_start_path", '')) file_dialog.setWindowTitle("Open File") file_dialog.setViewMode(QFileDialog.ViewMode.Detail) file_dialog.setFileMode(QFileDialog.FileMode.ExistingFile) if file_dialog.exec(): selected_file = file_dialog.selectedFiles()[0]
-
@Dwarrel
Although I am not sure, I thinklibqgtk3.so
is to do with display/how your dialog might look.
Start by Googling:undefined symbol: FT_Get_Transform
. You get a few hits aboutlibharfbuzz
. Have a read through those, e.g. maybe you have to install something else on whatever Linux distro you are using?
I am not sure what aspect of running under PyCharm makes it different from from command-line, but I would start by investigating the message. Maybe you have more than onelibharfbuzz.so
in existence? -
Thank you, from this suggestion I found this post stackoverflow. Pointing me to PYTHONPATH which is something that is set in pycharm.
Exporting (in the terminal before running) the identical PYTHONPATH that I got from pycharm (run code with prin(os.environ)) gave me the identical file explorer box. I identified the follow path that changes if it works or not:
/home/dwarrel/.local/share/JetBrains/Toolbox/apps/pycharm-professional/plugins/python/helpers/pycharm_matplotlib_backend
If that is set in pythonpath variable I get the explorer that I want. Within this folder I did not find any reference for libqgtk3. I kinda assume that loading the matplotlib backend changes something about the file explorer used.
Clearly this is not a solution or explanation of what is going on, however for my current purpose this is good enough.
Thanks for the help.