Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.12.x not compatible by default with flet (not able to be run) #1962

Closed
ehlui opened this issue Oct 15, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@ehlui
Copy link

ehlui commented Oct 15, 2023

Description

I am using python 3.12.0 lts version for this issue.

When running my flet app with with flet run main.py it crashes with the following trace:

error message

flet run main.py
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "$PWD\.venv\Scripts\flet.exe\__main__.py", line 4, in <module>
  File "$PWD\.venv\Lib\site-packages\flet\cli\cli.py", line 6, in <module>     
    import flet.cli.commands.publish
  File "$PWD\.venv\Lib\site-packages\flet\cli\commands\publish.py", line 9, in 
<module>
    from distutils.dir_util import copy_tree
ModuleNotFoundError: No module named 'distutils'

Code example to reproduce the issue:

# code from flet example main page
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(target=main)

Describe the results you expected:
A windows displaying a counter as the example in flet.

error_Trace

Flet version (pip show flet):

Name: flet
Version: 0.10.3
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page:
Author: Appveyor Systems Inc.
Author-email: [email protected]
License: Apache-2.0
Location: $PATH\.venv\Lib\site-packages
Requires: copier, flet-runtime, packaging, qrcode, watchdog, websocket-client, websockets
Required-by:

Operating system:

  • Windows 10 x64

Additional environment details:
It was tried in CMD and PS1 , optaining the same error.


Workaround

I could solve this issue by installing setuptools along with my flet installation, as this error comes because python 3.12.x will no longer have this package by default.

Installing setuptools
image

Right after the installation
image

sources:

@FeodorFitsner
Copy link
Contributor

https://peps.python.org/pep-0632/#migration-advice

For these functions, and any others not mentioned here, you will need to reimplement the functionality yourself. The legacy documentation can be found at https://docs.python.org/3.9/distutils/apiref.html

🥹

@FeodorFitsner FeodorFitsner added the bug Something isn't working label Oct 19, 2023
zrr1999 pushed a commit to zrr1999/flet that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants