Search code examples
pythonuser-interfacekivykivymdwindowed

How to convert kivy application to exe with --windowed mode ? there are some errors


I'm using python 3.8 ,and kivy version is 2.2.1 , I tried to convert a little kivy application to exe using pyinstaller.

if I used this command > pyinstaller main.py it's working normally without raise any error, but it show the console. I don't want it.

if I use --windowed , -w or --noconsole flags the software raise an error.

Traceback (most recent call last):
  File "logging\__init__.py", line 1084, 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 1084, in emit
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

. . . same error again and again.. after those . .

File "logging\__init__.py", line 1002, in handleError
File "kivy\logger.py", line 390, in write
File "logging\__init__.py", line 1454, in warning
File "logging\__init__.py", line 1585, in _log
File "logging\__init__.py", line 1595, in handle
File "logging\__init__.py", line 1657, in callHandlers
File "logging\__init__.py", line 950, in handle
File "logging\__init__.py", line 1081, in emit
File "logging\__init__.py", line 925, in format
File "kivy\logger.py", line 540, in format
File "kivy\logger.py", line 424, in __init__
File "logging\__init__.py", line 318, in __init__
File "ntpath.py", line 216, in basename
File "ntpath.py", line 186, in split
File "ntpath.py", line 35, in _get_bothseps
RecursionError: maximum recursion depth exceeded while calling a Python object

why is this?

How do I solve this? It's working with console mode.


Solution

  • There was a change in the most recent version of pyinstaller, you can read about the issue and fixes here: https://github.com/kivy/kivy/issues/8074

    At top of your main.py file, before importing any kivy files add:

    import os
    import sys
    if hasattr(sys, '_MEIPASS'):
        os.environ['KIVY_NO_CONSOLELOG'] = '1'