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

uvicorn unable to configure Formatter 'Default' #7339

Closed
AlbelTec opened this issue Dec 20, 2022 · 1 comment
Closed

uvicorn unable to configure Formatter 'Default' #7339

AlbelTec opened this issue Dec 20, 2022 · 1 comment
Labels
not-our-bug solution:won't fix Resolved: Maintainers will not fix this.

Comments

@AlbelTec
Copy link

Windows 11
Python 3.11
Pyinstaller 5.7.0

When I'm running my fastapi app by the python interpreter everything goes fine. But when creating .exe file with pyinstaller, I'm geeting this error and crashes the .exe file.

My comand :

pyinstaller --noconfirm --onedir --windowed --icon "D:/classifier/neural.ico" --add-data "D:/classifier/model;model/" --collect-all "spacy" --collect-all "thinc" --collect-submodules "spacy_legacy" --copy-metadata "spacy_legacy" --collect-submodules "uvicorn" --collect-submodules "sklearn" --hidden-import "blis" --hidden-import "preshed" --hidden-import "fr_core_news_sm" --hidden-import "en_core_web_sm" --hidden-import "uvicorn" --hidden-import "uvicorn.logging" --paths "D:/classifier" --collect-submodules "D:/classifier" "D:/launcher.py"

Traceback (most recent call last):
  File "logging\config.py", line 541, in configure
  File "logging\config.py", line 653, in configure_formatter
  File "logging\config.py", line 472, in configure_custom
  File "uvicorn\logging.py", line 47, in __init__
    self.use_colors = sys.stdout.isatty()
                      ^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'isatty'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "launcher.py", line 47, in <module>
  File "uvicorn\main.py", line 506, in run
    config = Config(
             ^^^^^^^
  File "uvicorn\config.py", line 299, in __init__
    self.configure_logging()
  File "uvicorn\config.py", line 407, in configure_logging
    logging.config.dictConfig(self.log_config)
  File "logging\config.py", line 812, in dictConfig
  File "logging\config.py", line 544, in configure
ValueError: Unable to configure formatter 'default'

Any insight ?

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

rokm commented Dec 20, 2022

AttributeError: 'NoneType' object has no attribute 'isatty'

See https://pyinstaller.org/en/v5.7.0/CHANGES.html#incompatible-changes; as of PyInstaller 5.7, sys.stdout and sys.stderr are None in windowed/noconsole mode, same as if you ran your script under pythonw.exe.

EDIT: since the error is originating from uvicorn.logging, either report the problem to uvicorn, or, as a work-around, override sys.stdout and sys.stderr with dummy file objects at the start of your program, as discussed in #7325.

@rokm rokm closed this as not planned Won't fix, can't repro, duplicate, stale Dec 20, 2022
@rokm rokm added solution:won't fix Resolved: Maintainers will not fix this. not-our-bug and removed triage Please triage and relabel this issue labels Dec 20, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 19, 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