Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use terminal from a fbs packaged App #251

Open
G-Siron opened this issue Sep 27, 2021 · 15 comments
Open

Use terminal from a fbs packaged App #251

G-Siron opened this issue Sep 27, 2021 · 15 comments

Comments

@G-Siron
Copy link

G-Siron commented Sep 27, 2021

Hi Michael!

I am trying to use the console from a fbs packaged App (python 3.9.4, fbs 1.0.6, Pyinstaller 4.5.1, PyQt5 5.15.4). I need to use fortran executable files from another developper, I basically only change the input files and read the outputs from these executables. This work fine when using the App from the terminal (either with the "fbs run" command or after freezing using the executable file in the target/App_name folder). But when I try to use it directly from the GUI App it doesn't work. I suspect that it cannot open a terminal session. Do I have to build a console App or is this something that could still be possible otherwise?

I am on a Mac but I plan to distribute Windows and Linux versions as well.

Thank you in advance for the response and thank you for this wonderful package!

Best,
Guillaume

@mherrmann
Copy link
Owner

Hi, does the problem go away when you downgrade to PyQt5 5.15.3?

@G-Siron
Copy link
Author

G-Siron commented Sep 27, 2021

No it didn't change anything. Just to be clear, I ask the user to specify the folder in which the input and executable files are and I am moving in this folder to execute the executable this way:

os.chdir(path_to_folder)
os.system("./executable_name")

I don't want to bundle the executable within the App sine it is developed by someone else so that the user can update the executable independently and I don't have to update the App every time the developper update the executable files. But if that's the only solution I could settle with that. Using the terminal from a GUI App is something that has been done with fbs before?

@mherrmann
Copy link
Owner

I'm not sure I understand 100% what you mean. Do you get what you want when you add

"show_console_window": true

to src/build/settings/base.json?

@G-Siron
Copy link
Author

G-Siron commented Sep 27, 2021

It doesn't produce a standalone App that I could distribute as an installer (but I guess that's the point). Is that a limitation of fbs that we cannot use the terminal when we want to distribute solely a GUI App?
If so I can always compress the whole folder and ask people to unzip it and use the terminal to start the program which is an improvement compare to asking people to install python and the different packages.

@mherrmann
Copy link
Owner

What you write confuses me in so many ways.

It doesn't produce a standalone App that I could distribute as an installer

fbs freeze produces a standalone app. fbs installer produces an installer for it.

Is that a limitation of fbs that we cannot use the terminal when we want to distribute solely a GUI App?

show_console_window which I quoted above precisely enables a Terminal window when your app is launched.

I can always compress the whole folder and ask people to unzip it and use the terminal to start the program which is an

I believe you will get what you want with fbs installer and show_console_window: true.

@G-Siron
Copy link
Author

G-Siron commented Sep 27, 2021

When I add the "show_console_window : true" in the json setting file, it doesn't produce a standalone App. It produce a 929 bytes file that cannot be used (and then fbs installer doesn't do anything). But I can still start the application through the executable file in target/App_name.
Edit: fbs installer creates an installer but the App just show an error message, exactly like when trying to open it directly after fbs freeze.

@mherrmann
Copy link
Owner

mherrmann commented Sep 27, 2021

Please, in all of your future messages, provide me with more, painstaking detail and context. I feel like I have to ask for more context every time you post, when you could have given it to begin with.

Here, you write "... the app just shows an error message". What is the error message?

Also, you write "it produces a 929 bytes file that cannot be used". But then, you write "but I can still start the application through target/App_name". So what does it mean when you say "it cannot be used"?

I wrote a post that gives more examples of the information I need to be able to help you: https://gist.github.com/mherrmann/4574c938bd610eb1183f3cc2200d6166

Please, please, please. Give me more detail. Tell me exactly what you are doing. Send me errors. Don't write "it doesn't work" or "it doesn't do anything". Write "I double-click target/App. I would have expected my app to open. But nothing happened. When I then typed in target/App/Contents/MacOs/App into the Terminal, I got the following error: ...".

@G-Siron
Copy link
Author

G-Siron commented Sep 27, 2021

Sorry, I will try to be more specific.

The error message when I try with "show_console_window : true" is just: You can't open the application "App name.app" because it may be damaged or incomplete.
This is the same whether I double click on the App created after fbs freeze or the App from my application folder after using fbs installer.

After using fbs freeze, I can use the GUI application launching from the terminal using the executable file located in the folder target/App_name. This work fine and I even tried compressing this folder (target/App_name folder), copying it somewhere else, unzipping it and launching the GUI App from the terminal using the executable from the unzipped folder. It works fine too.
But if I try to create a standalone App without the "show_console_window : true", it does create a standalone App (and I can create an installer). I can start the App without any issue, I can enter the different informations I need, see attached file (some numbers in lineEdit fields, directories for the fortran executables I need to use), but it seems that it doesn't access the fortran executable files that I need to run. At least when I click the "run" pushbutton, nothing happen.
The fortran executable files are located in other folders (which is why I need their path as input from the user).

I am on MacOS 11.0.1 (I didn't try on another OS).
Screen Shot 2021-09-27 at 17 16 48

@mherrmann
Copy link
Owner

Thank you for the detail. Do you see any interesting output (such as errors) when you run the frozen app by typing the following into the terminal?

target/App_name.app/Contents/MacOs/App_name

@mherrmann
Copy link
Owner

(If you don't see anything, try after fbs freeze --debug.)

@G-Siron
Copy link
Author

G-Siron commented Sep 27, 2021

Without --debug:
With the "show_console_window : true", there is not MacOS folder in the folder target/App_name.app/Contents. Just the info.plist file.

Without the "show_console_window : true", it works fine, I can see in the terminal that the fortran executables are correctly executed.

With --debug:
When running using "target/App_name.app/Contents/MacOs/App_name", it works as intended.

With the "show_console_window : true", it does creates a standalone App that is roughly the same size (255.8 Mo vs 241 Mo without "show_console_window : true" and without --debug). But what it seems is that it stuck after executing the first fortran executable. At least the outputs from that first fortran executable are what is expected and the same than what I have when I run through the terminal (using "target/App_name.app/Contents/MacOs/App_name"). But then it stuck before being able to modify the input file from the second fortran executable.

Here is the steps of the script:

  1. move to folder_1
  2. execute fortran_exec_1
  3. read output_1 from fortran_exec_1 and store the information
  4. move to folder_2
  5. read input_2 for fortran_exec_2 to locate the part to delete at the end
  6. remove the end
  7. write the output_1 from fortran_exec_1 at the end of input_2
  8. execute fortran_exec_2

From the files inside folder_1, steps 1 and 2 are correctly executed. Then I don't know if it does 3 and 4 since there is nothing displayed. But for sure it is stuck before 5).
So it is communicating with the terminal to execute the fortran executables but then is lost at some point. I will try to add a QMessageBox that pops up between 2 and 3 and between 3 and 4 to see where it is stuck.

When I have done that I will come back to you.

@G-Siron
Copy link
Author

G-Siron commented Sep 28, 2021

So it looks like it stuck at step 5. The line is just:
for num, line in enumerate(file_EQ6, 0):
It is weird since the exact same line is written 10 lines before and works perfectly... I don't think it is something only related to fbs even if it works fine except for the standalone App. I will look into it.

Thank you for your help trying to solve this. When I find what was wrong I will update you.

@mhogg
Copy link

mhogg commented Jan 19, 2022

Hi @mherrmann,

I think I have the same issue as described in this thread. I am running on macOS 11.5 using Python 3.8, PySide6 6.2 and fbs Pro 1.0.8.

During freezing, I have issues when I add "show_console_window": true to build/settings/mac.json . I have been able to replicate this issue creating a new project using fbs startproject with all the defaults and then adding "show_console_window": true. Note that freeze works ok if "show_console_window": false is used.

What is the actual error when using "show_console_window": true?

  • When I run fbs freeze, the resulting MyApp.app file is damaged as shown in image

Screen Shot 2022-01-19 at 4 38 12 pm

  • When I run fbs freeze --debug, MyApp.app is created (see image) but the console is not shown when MyApp.app is run.

Screen Shot 2022-01-19 at 4 44 21 pm

I am not sure why fbs freeze works with --debug but not without. But the common factor appears to be using "show_console_window": true. I haven't experienced this issue on Windows.

Any ideas?

Michael

@mherrmann
Copy link
Owner

@mhogg what show_console_window does is to remove the --windowed flag that fbs passes to PyInstaller. I've recently heard of problems with Big Sur and looking online, it also appears that PyInstaller may have problems with it.

Are you able to reproduce the problem on a lower macOS version? Sorry if this is a pain to test. In general for compatibility, fbs's manual advises to build on as early an OS version as possible for maximum compatibility.

@mhogg
Copy link

mhogg commented Jan 21, 2022

That makes sense @mherrmann - thanks for your comment. In terms of testing - I only have access to Big Sur, but I might know someone who has an earlier version. I can confirm that freezing with show_console_window set to true works on Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants