Hi Alisha,
I have seen this problem before and eventually figured out the cause. You are directly or indirectly using either stdout or stderr as an out put for logger but pyinstaller and some or most exe builders produce exes which, when running in Windowed mode, set both of these to None and logger fails like this because None as the exception says doesn’t have an istty or any other methods.
Some possible solutions include:
Hope that this helps.
Steve
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pyinstaller...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/4ff86e8c-5ccb-48c4-a608-c5495c92ad35n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/DU0P194MB18196E90634DD627C520F6D29B659%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.
You received this message because you are subscribed to a topic in the Google Groups "PyInstaller" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pyinstaller/w4EXpztCafE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/DU0P194MB18196E90634DD627C520F6D29B659%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.
On Apr 25, 2023, at 11:42 PM, Steve Barnes <Gadge...@live.co.uk> wrote:
Hi Alisha,
I have seen this problem before and eventually figured out the cause. You are directly or indirectly using either stdout or stderr as an out put for logger but pyinstaller and some or most exe builders produce exes which, when running in Windowed mode, set both of these to None and logger fails like this because None as the exception says doesn’t have an istty or any other methods.
Some possible solutions include:
- Set the application to be a console application so that it will open a terminal window (it can still use the GUI but log messages will go to the terminal quick but dirty
- If the application has the frozen attribute or set sys.stdout is None and no log file is specified then create your logger with the file set to os.devnull this will discard all logs
- Use logging.NullHandler if frozen or sys.stdout is None.
- Always log to a file but please consider using logging.RotatingFileHandler as the default handler if frozen or sys.stdout is None.
Hope that this helps.
Steve
From: pyins...@googlegroups.com <pyins...@googlegroups.com> On Behalf Of Alisha Jain
Sent: Monday, April 24, 2023 5:14 PM
To: PyInstaller <pyins...@googlegroups.com>
Subject: [PyInstaller] ValueError: Unable to configure formatter 'default'
Hi,
I creating a python application which uses uvicorn module. The code runs successfully, however, when I create a exe using pyinstaller, It is able to create the executable but I see following error when I run the exe file. Please help.
<image001.png>
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/4ff86e8c-5ccb-48c4-a608-c5495c92ad35n%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyinstaller...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/DU0P194MB18196E90634DD627C520F6D29B659%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.
Hi Chris,
The python standard library os.devnull gives an operating system independent equivalent to /dev/null (IIRC it actually maps to /dev/null on *nix systems) – including MS Windows.
I have suggested in the past that python exe generators could/should set both stdout and stderr to os.devnull for windowed exes rather than using None in that case.
All the best,
Steve Barnes
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/931E8665-50B5-4BAC-A4E6-09C5A5F02546%40noaa.gov.
Eric,
Good Idea & done with the os.devnull solution!
Steve
From: pyins...@googlegroups.com <pyins...@googlegroups.com> On Behalf Of Eric Fahlgren
Sent: Wednesday, April 26, 2023 3:09 PM
To: pyins...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/CAP2Qz%2BXLubZckCgfL_aJriL1yu3fd4p%2Bn1P0VRPOXESNLeA-RA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyinstaller/DU0P194MB18199CB7A26C857CAF04E9B99B659%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.
But is it possible that PyInstaller could do it by default for Windows apps?
I’d be rather raise the question of why doesn’t pythonw.exe do it by default.
We don’t particularly like adding accommodations for broken code and, with Python’s current handling of windowed mode (even though almost no one realises that it exists), any direct access to the standard pipes without checking they’re not None is broken code.
But is it possible that PyInstaller could do it by default for Windows apps?
I’d be rather raise the question of why doesn’t pythonw.exe do it by default.
We don’t particularly like adding accommodations for broken code and, with Python’s current handling of windowed mode (even though almost no one realises that it exists), any direct access to the standard pipes without checking they’re not None is broken code.
On a semi-related note, I think we need to reword that piece of documentation. The recommended approach is to wrap your own usages of sys.stderr and sys.stdout in is not None checks and to encourage offending libraries to do the same. The os.devnull hack is suggested only as a last resort in case library maintainers refuse to add their own guards. However, everyone seems to be misinterpreting it as the recommended fix.