Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 04-23-2024, 01:26 PM   #1
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
Question regarding program call

Hi there,

I'm facing a problem:

I have build a python program with a PyQt6 Gui from which I call Sigil with
a subprocess function to start with a certain epub file to edit.
When I start the python program directly everything is fine. When I compile
everything I get the following error:

This application failed to start because no Qt platform plugin could be
initialzed. Reinstalling the application may fix this problem.
Available platform plugins are: minimal, offscreen, windows.


Is there anything I can do to avoid this????

Thanks for any positive answer
docjc is offline   Reply With Quote
Old 04-23-2024, 03:46 PM   #2
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,160
Karma: 5450818
Join Date: Nov 2009
Device: many
You did not say what platform you are using?

Sigil in Windows and macOS embeds its own Python interpreter and its own PySide6 version. If those two Qt versions differ then issues arise. On Linux, there is a script to set the ld library path and other sundries.

That said, passing a path to an epub as the first argument to Sigil works well on all platforms.

So why not a shell or batch file to launch Sigil passing in the path to the epub you want to edit if simply adding it on the command line is an issue.

Or try creating a python subprocess with its own shell to invoke Sigil.

Last edited by KevinH; 04-23-2024 at 06:06 PM.
KevinH is offline   Reply With Quote
Advert
Old 04-23-2024, 08:55 PM   #3
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,044
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Whatever you're using to freeze/compile your Python program may not be properly including/handling the necessary Qt dependencies/locations. Python compilers typically require special configs to deal with (Py)Qt.

From your description, it's hard to tell whether it's your compiled Python program that's failing to find Qt, or Sigil itself. The fact that you say everything works without freezing your python program suggests to me that it's the former.

It's also possible that the freezing involves setting certain Qt runtime environment variables that could definitely break Sigil's ability to find it's own Qt elements.

Using a compiled Python/Qt program to launch another C++/Qt program via a subprocess is always going to be fraught with peril (because of the environment the subprocess inherits). You're probably going to have to find a way to sanitize the environment used by the subprocess launching Sigil.

Last edited by DiapDealer; 04-23-2024 at 09:22 PM.
DiapDealer is online now   Reply With Quote
Old 04-24-2024, 05:44 AM   #4
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
@KevinH

Quote:
Originally Posted by KevinH View Post
You did not say what platform you are using?

...

That said, passing a path to an epub as the first argument to Sigil works well on all platforms.

So why not a shell or batch file to launch Sigil passing in the path to the epub you want to edit if simply adding it on the command line is an issue.

Or try creating a python subprocess with its own shell to invoke Sigil.
Hi,
thank you for quickly answering

I forgot to say it is windows 11 PyQt6 latest version (maybe I should switch to PySide)

As I said, running as a python file works fine, no problem. Using PyInstaller to "compile" is the problem. As the epub file is defined during the process the batch file must also be generated during the process. I will try to do so. I have had the same idea generating to own shell for Sigil, but this gave the same result as before.

I'll keep you informed
docjc is offline   Reply With Quote
Old 04-24-2024, 10:24 AM   #5
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,044
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
To be clear: when, exactly, does the error occur?

When you try to launch your PyInstaller-compiled program?

Or when you try to launch Sigil from your already successfully running PyInstaller-compiled program?

If it's the former, you might need to research how to include your qt plugins folder with your PyInstaller build.
DiapDealer is online now   Reply With Quote
Advert
Old 04-26-2024, 01:59 AM   #6
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
The issue starts when I call sigil. I have tried to call Sigil via batch file and in an extra shell, nothing works really. Normally 2 different instances of Qt at the same time are working (Sigil and Calibre on the same computer, but different shells). So for me it is not quite clear how to separate the Python/Qt shell from the Sigil/Qt shell. I did it via subprocess(…..shell=True), is there a better way?
docjc is offline   Reply With Quote
Old 04-26-2024, 07:56 AM   #7
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
additionally I have to mention that the error message is coming from Sigil after calling Sigil by "subprocess.Popen([sigil_path, epub_file_path], shell = True)". Running the py file gives no error and everything is fine.
docjc is offline   Reply With Quote
Old 04-26-2024, 09:04 AM   #8
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,044
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
I've rarely found a need for shell=True on Windows myself.

The described behavior still makes me think that part of PyInstaller's PyQt6 freezing strategy involves setting some Qt environment variable(s). You could try dumping the environment to a msgbox (before the subprocess call to launch Sigil) and look for something like QT_QPA_PLATFORM_PLUGIN_PATH. That would definitely cause issues if set. If it is, you could pass a sanitized env parameter to the subprocess.Popen call with all Qt/Python environment variables removed.

Something else to try is passing the cwd parameter to the subprocess.Popen call and setting it to Sigil's program directory (making sure to use a relative path to Sigil's exe rather than the full path).

Last edited by DiapDealer; 04-26-2024 at 09:32 AM.
DiapDealer is online now   Reply With Quote
Old 04-26-2024, 04:58 PM   #9
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,044
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Did a quick test and PyInstaller definitely creates a slightly different env when compiled than it does when running as a script. It prepends an extra item to the PATH variable, and also sets the QT_PLUGIN_PATH to its own PyQt6 plugins folder. THAT will definitely affect Sigil adversely when launching via a subprocess. You'd need to scrub that (and the QML2_IMPORT_PATH for good measure) variable from a copy of the system environment and pass that via the env parameter to subprocess.Popen().

Hope something there helps.
DiapDealer is online now   Reply With Quote
Old 04-28-2024, 10:27 AM   #10
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
sorry for not answering earlier, something else to do
Thank you for your efforts to solve the problem, This morning I did something else: I used calibre-edit.exe instead of sigil and this works fine even after compilation. After reading your mails I've got the idea to add sigil to the path and call just sigil and not the full path. I will try this and keep you informed.
docjc is offline   Reply With Quote
Old 04-28-2024, 11:48 AM   #11
docjc
Member
docjc began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Aug 2020
Device: Kobo
The idea with the path wasn't successful, now I will try your proposal
docjc is offline   Reply With Quote
Old 04-28-2024, 03:41 PM   #12
DiapDealer
Grand Sorcerer
DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.DiapDealer ought to be getting tired of karma fortunes by now.
 
DiapDealer's Avatar
 
Posts: 28,044
Karma: 199464182
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
Quote:
Originally Posted by docjc View Post
sorry for not answering earlier, something else to do
Thank you for your efforts to solve the problem, This morning I did something else: I used calibre-edit.exe instead of sigil and this works fine even after compilation.
Kovid patches his Qt so the plugins path can be set before calibre runs. We typically only patch what's necessary to fix Qt bugs that adversely affect Sigil.
DiapDealer is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
want free call phone program dentist.barakat enTourage eDGe 1 10-14-2011 05:54 PM
Question Regarding "Juicing" with Smashwords Affiliate Program GoblinWriter Writers' Corner 0 02-18-2011 02:03 AM
PDF program question jblitereader General Discussions 9 07-25-2010 12:33 AM
Question about ummmm not sure what to call it artemisblossom Sony Reader 14 06-25-2009 08:06 AM


All times are GMT -4. The time now is 04:31 PM.


MobileRead.com is a privately owned, operated and funded community.