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

v5.7.0 -w package flask to run .exe file error #7325

Closed
yangyuexiong opened this issue Dec 14, 2022 · 3 comments
Closed

v5.7.0 -w package flask to run .exe file error #7325

yangyuexiong opened this issue Dec 14, 2022 · 3 comments
Labels
not-our-bug solution:won't fix Resolved: Maintainers will not fix this.

Comments

@yangyuexiong
Copy link

After upgrading to v5.7.0, -w packaged the flask application, and an error occurred when running .exe. Try to add the following code in the entry file to solve this problem, and it can run successfully. If you don't add this code block, is there any other way to solve it?

image

`
import os
import sys

import PyInstaller

if PyInstaller.version == "5.6.2":
pass
else:
sys.stdout = open(os.devnull, "w")
`

@yangyuexiong yangyuexiong added the triage Please triage and relabel this issue label Dec 14, 2022
@rokm
Copy link
Member

rokm commented Dec 14, 2022

If you don't add this code block, is there any other way to solve it?

No. If you use noconsole/windowed mode, you now need to set a fake sys.stdout yourself. Same as if you ran your python code in noconsole pythonw.exe interpreter.

If you want this to work without setting fake sys.stdout yourself, you should ask either flask maintainers to not call show_server_banner when sys.stdout is unavailable, or ask click maintainers to gracefully handle cases when click.utils.echo is called with unavailable file handle.

@rokm rokm added solution:won't fix Resolved: Maintainers will not fix this. and removed triage Please triage and relabel this issue labels Dec 14, 2022
@rokm rokm closed this as not planned Won't fix, can't repro, duplicate, stale Dec 14, 2022
@rokm
Copy link
Member

rokm commented Dec 14, 2022

Also, you should not be importing PyInstaller in your application. You can safely override sys.stdout even when using PyInstaller < 5.7.

@rokm
Copy link
Member

rokm commented Dec 14, 2022

I've opened issue with click (pallets/click#2415) - as they are advertising click.utils.echo as replacement for print, they should be properly handling the case when console is unavailable.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
not-our-bug solution:won't fix Resolved: Maintainers will not fix this.
Projects
None yet
Development

No branches or pull requests

2 participants