application fails in no-console mode

31 views
Skip to first unread message

Glen Rubin

unread,
Feb 16, 2023, 10:20:59 AM2/16/23
to PyInstaller
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 ...


Steve Barnes

unread,
Feb 16, 2023, 11:58:47 AM2/16/23
to pyins...@googlegroups.com

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

--
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/dfcf25c5-9da5-4802-88e4-fc72a2d8586en%40googlegroups.com.

Glen Rubin

unread,
Feb 17, 2023, 3:24:47 AM2/17/23
to pyins...@googlegroups.com
Steve,
Thanks for responding!  Prior to encountering this issue, I was not initializing any logging.  I am trying now to explicitly turn off kivy logging in my main.py file but am still coming up against the same problem.  Here is what I just added to my main.py:

from kivy.logger import Logger
from kivy.config import Config
Config.set('kivy', 'log_enable', False)
Config.set('graphics','width','360')
Config.set('graphics','height','760')
import os
os.environ["KIVY_NO_CONSOLELOG"] = "1"
os.environ["KIVY_NO_FILELOG"] = "1"


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/-LpzPG4S8L0/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/DU0P194MB18197302A991A9553CC82EB69BA09%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.

Glen Rubin

unread,
Feb 17, 2023, 3:25:01 AM2/17/23
to pyins...@googlegroups.com
I just found kivy config.ini file and set log_enable = 0

no difference

Chris Barker

unread,
Feb 17, 2023, 3:25:10 AM2/17/23
to pyins...@googlegroups.com
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 <Gadge...@live.co.uk> wrote:


--

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....@noaa.gov

Steve Barnes

unread,
Feb 17, 2023, 4:59:40 AM2/17/23
to pyins...@googlegroups.com

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

Glen Rubin

unread,
Feb 18, 2023, 4:07:48 AM2/18/23
to pyins...@googlegroups.com
Ok, I found the issue, and you'll have to forgive me since it's pretty simple.  In the kivy config.ini file debug was turned on.  I'm pretty green at coding, config files, and python in general...so took me a while to figure this out...sorry to bother the group.

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/-LpzPG4S8L0/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/DU0P194MB1819FE8A146B3B2A383506A69BA19%40DU0P194MB1819.EURP194.PROD.OUTLOOK.COM.

Chris Barker

unread,
Feb 18, 2023, 4:08:01 AM2/18/23
to pyins...@googlegroups.com
On Fri, Feb 17, 2023 at 1:59 AM Steve Barnes <Gadge...@live.co.uk> wrote:

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


Is that sys.FROZEN ?

Good to know for other things as well.

-CHB

 

Reply all
Reply to author
Forward
0 new messages