One "trick" that I have used several times is:
# If no output channels set them to the OS bitbucket.
if sys.stderr is None: sys.stderr = open(os.devnull, "w")
if sys.stdout is None: sys.stdout = open(os.devnull, "w")
This needs to be done before importing anything like or that uses logging this 
will allow logging to carry on as before but all of the output will disappear. 
It might be worth raising an issue on KIVY to suggest something similar or 
another resolution.

BTW: Most python to executable converts set a FROZEN attribute but I have found 
that it is not 100% reliable hence the above.

Steve

From: 'Chris Barker' via PyInstaller <pyinstaller@googlegroups.com>
Sent: 16 February 2023 18:50
To: pyinstaller@googlegroups.com
Subject: Re: [PyInstaller] application fails in no-console mode

NOTE: I don't remember the invocation, but there should be a way to check at 
runtime if the app is running as a stand-alone, and conditionally set up 
logging or whatever differently.

-CHB


On Thu, Feb 16, 2023 at 8:58 AM Steve Barnes 
<gadgetst...@live.co.uk<mailto:gadgetst...@live.co.uk>> wrote:
I have come across similar before. You probably have logger set to write to 
stdout &/or stderr, however, in the compiled application stdout, stderr = None, 
None hence the errors. The trick that I used was to check if they are currently 
None and if so either don't initialise the logger or make sure that all logging 
is sent to a file.

Hope that helps.

Steve

From: pyinstaller@googlegroups.com<mailto:pyinstaller@googlegroups.com> 
<pyinstaller@googlegroups.com<mailto:pyinstaller@googlegroups.com>> On Behalf 
Of Glen Rubin
Sent: 16 February 2023 14:54
To: PyInstaller 
<pyinstaller@googlegroups.com<mailto:pyinstaller@googlegroups.com>>
Subject: [PyInstaller] application fails in no-console mode

My 'compiled' application fails, but only on Windows when setting console 
option to False.
At fail i get the error:

Failed to execute script 'main' due to unhandled exception: maximum recursion 
depth exceeded

with a very long traceback that looks like this:

Traceback (most recent call last):
  File "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'

This repeats a few thousand times and then prints:

Traceback (most recent call last):
  File "logging\__init__.py", line 1103, in emit
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "kivy\logger.py", line 248, in emit
  File "kivy\logger.py", line 222, in _configure
  File "logging\__init__.py", line 1477, in info
  File "logging\__init__.py", line 1624, in _log
  File "logging\__init__.py", line 1634, in handle
  File "logging\__init__.py", line 1696, in callHandlers
  File "logging\__init__.py", line 968, in handle
  File "logging\__init__.py", line 1108, in emit
  File "logging\__init__.py", line 1021, in handleError
  File "kivy\logger.py", line 338, in write
  File "logging\__init__.py", line 1489, in warning
  File "logging\__init__.py", line 1624, in _log
  File "logging\__init__.py", line 1634, in handle
  File "logging\__init__.py", line 1696, in callHandlers
  File "logging\__init__.py", line 968, in handle
  File "logging\__init__.py", line 1108, in emit
  File "logging\__init__.py", line 1021, in handleError
  File "kivy\logger.py", line 338, in write
  File "logging\__init__.py", line 1489, in warning
  File "logging\__init__.py", line 1624, in _log
  File "logging\__init__.py", line 1634, in handle
  File "logging\__init__.py", line 1696, in callHandlers
  File "logging\__init__.py", line 968, in handle
  File "logging\__init__.py", line 1108, in emit
  File "logging\__init__.py", line 1021, in handleError
  File "kivy\logger.py", line 338, in write
  File "logging\__init__.py", line 1489, in warning
  File "logging\__init__.py", line 1624, in _log
  File "logging\__init__.py", line 1634, in handle
  File "logging\__init__.py", line 1696, in callHandlers
  File "logging\__init__.py", line 968, in handle
  File "logging\__init__.py", line 1108, in emit
  File "logging\__init__.py", line 1021, in handleError
  File "kivy\logger.py", line 338, in write
  File "logging\__init__.py", line 1489, in warning ...


--
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+unsubscr...@googlegroups.com<mailto:pyinstaller+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/dfcf25c5-9da5-4802-88e4-fc72a2d8586en%40googlegroups.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2Fdfcf25c5-9da5-4802-88e4-fc72a2d8586en%2540googlegroups.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7C%7C57457cf5ed454dee2e8d08db10c07c37%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638122191121868886%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=0T5s1Sl9OEr20WdwWwvn8%2BanSwhgiLZmJX9y7dWCSro%3D&reserved=0>.
--
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+unsubscr...@googlegroups.com<mailto:pyinstaller+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/DU0P194MB18197302A991A9553CC82EB69BA09%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2FDU0P194MB18197302A991A9553CC82EB69BA09%2540DU0P194MB1819.EURP194.PROD.OUTLOOK.COM%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7C%7C57457cf5ed454dee2e8d08db10c07c37%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638122191121868886%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=waIvTgw8P6RjPvX1O43Z3GpSTNrrvYzE9QdDJkeniHA%3D&reserved=0>.


--

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

chris.bar...@noaa.gov<mailto:chris.bar...@noaa.gov>
--
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+unsubscr...@googlegroups.com<mailto:pyinstaller+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/CALGmxELkz_OmgHX8gMzMd3O%3DkkHxLTYHgzzMRENUTonOge7WZg%40mail.gmail.com<https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fpyinstaller%2FCALGmxELkz_OmgHX8gMzMd3O%253DkkHxLTYHgzzMRENUTonOge7WZg%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&data=05%7C01%7C%7C57457cf5ed454dee2e8d08db10c07c37%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638122191121868886%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=6b11xrLv605YdBtdwAA3Wt1%2F5QEcNa%2Fv6MR7HAkeMHY%3D&reserved=0>.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyinstaller/DU0P194MB1819FE8A146B3B2A383506A69BA19%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.

Reply via email to