0

I encountered an error to convert counter app written with python flet framework to exe using with auto-py-to-exe.

Here is my code;

    import sys
sys.setrecursionlimit(sys.getrecursionlimit() * 5)
import flet as ft

def main(page: ft.Page):
    page.title = "Flet counter example"
    page.vertical_alignment = ft.MainAxisAlignment.CENTER

    txt_number = ft.TextField(value="0", text_align=ft.TextAlign.RIGHT, width=100)

    def minus_click(e):
        txt_number.value = str(int(txt_number.value) - 1)
        page.update()

    def plus_click(e):
        txt_number.value = str(int(txt_number.value) + 1)
        page.update()

    page.add(
        ft.Row(
            [
                ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
                txt_number,
                ft.IconButton(ft.icons.ADD, on_click=plus_click),
            ],
            alignment=ft.MainAxisAlignment.CENTER,
        )
    )

ft.app(main)

I wrote auto-py-to-exe in terminal, and select main.py file where the code is in.

The error was occured;

An error occurred while packaging
Traceback (most recent call last):
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call
    return isolated.call(function, *args, **kwargs)
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 293, in call
    ok, output = loads(b64decode(self._read_handle.readline()))
EOFError: EOF read where object expected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\auto_py_to_exe\packaging.py", line 131, in package
    run_pyinstaller()
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 180, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\__main__.py", line 61, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 1006, in main
    build(specfile, distpath, workpath, clean_build)
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 928, in build
    exec(code, spec_namespace)
  File "C:\Users\Lenovo\AppData\Local\Temp\tmprfg02jem\main.spec", line 7, in <module>
    a = Analysis(
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 428, in __init__
    self.__postinit__()
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
    self.assemble()
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\building\build_main.py", line 736, in assemble
    isolated.call(find_binary_dependencies, self.binaries, self.binding_redirects, collected_packages)
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 372, in call
    return isolated.call(function, *args, **kwargs)
  File "C:\Users\Lenovo\anaconda3\lib\site-packages\PyInstaller\isolated\_parent.py", line 247, in __exit__
    self._write_handle.flush()
OSError: [Errno 22] Invalid argument

Project output will not be moved to output folder
Complete.

when i use flet pack your_program.py again i encountered problem, How can i solve this problem?

emrec
  • 1
  • 2
  • `sys.setrecursionlimit` is dangerous. You can end up with a crash, I guess it will be a segmentation fault. – colidyre Jun 07 '23 at 17:24

1 Answers1

0

Please always provide more Info, ex: how did you compile it? how does your code look? do you have an MRE? etc.

The docs state this: https://flet.dev/docs/guides/python/packaging-desktop-app/

Start from installing PyInstaller:

pip install pyinstaller

Navigate to the directory where your .py file is located and build your app with the following command:

flet pack your_program.py

NoBlockhit
  • 369
  • 2
  • 15