Skip to content

bug: Runtime packaged application fails with misleading module 'flet' has no attribute 'ElevatedButton' error #6894

Closed

Description

@nelson-python

Duplicate Check

Describe the bug

ENVIRONMENT

Windows 11
Python 3.13.14

Flet 0.86.3 (reproduced)
Flet 1.0.1 (reproduced)

Flutter 3.44.8

BUILD COMMAND

flet build windows -v

SUMMARY

A Flet application that uses:

ft.ElevatedButton(...)

...builds successfully, but the generated Windows executable fails at runtime with:

AttributeError: module 'flet' has no attribute 'ElevatedButton'

However, ElevatedButton clearly exists and can be imported and instantiated successfully from Python.

Replacing:

ft.ElevatedButton(...)

...with:

ft.Button(...)

...allows the executable to launch normally.

RUNTIME ERROR

The application encountered an error:
module 'flet' has no attribute 'ElevatedButton'

Traceback (most recent call last):
  File "C:\flutter\extension26\examples\test_extension_26_example\build\site-packages\flet\app.py", line 368, in on_session_created
  File "C:\Users\Nelso\AppData\Local\Temp\serious_python_tempXXXX\main.py", line 221, in main
  File "C:\Users\Nelso\AppData\Local\Temp\serious_python_tempXXXX\main.py", line 108, in build_canvas_toolbar
  File "C:\flutter\extension26\examples\test_extension_26_example\build\site-packages\flet\__init__.py", line 1818, in __getattr__
AttributeError: module 'flet' has no attribute 'ElevatedButton'

VERIFICATION PERFORMED

Verified that ElevatedButton exists:

import flet as ft

print(ft.ElevatedButton)

...results in:

<class 'flet.controls.material.elevated_button.ElevatedButton'>

Verified that it can be instantiated:

import flet as ft

b = ft.ElevatedButton("Test")

print(b)

...results in:

DeprecationWarning:
ElevatedButton is deprecated since version 0.80.0 and will be removed in version 1.0.
Use Button instead.
Button(...)

This demonstrates:

  1. ElevatedButton exists.
  2. ElevatedButton imports successfully.
  3. ElevatedButton can be instantiated successfully.
  4. The symbol is not actually missing.

WORKAROUND

Replace:

ft.ElevatedButton(...)

...with:

ft.Button(...)

The executable then launches normally.

Code sample

Code
import flet as ft

def main(page: ft.Page):
    page.add(
        ft.ElevatedButton(
            "Test"
        )
    )

ft.app(main)

To reproduce

flet build windows

Expected behavior

EXPECTED BEHAVIOR

Either:

ft.ElevatedButton(...)

...should continue working while the API exists, or the runtime should produce an explicit deprecation/removal message such as:

ElevatedButton is deprecated.
Use ft.Button instead.

ACTUAL BEHAVIOR

A runtime error is generated:

module 'flet' has no attribute 'ElevatedButton'

...even though:

print(ft.ElevatedButton)

...and:

ft.ElevatedButton("Test")

...succeed in Python.

Screenshots / Videos

Captures Image

Operating System

Windows

Operating system details

Windows 11 Professional

Flet version

1.0.1 and 0.86.3

Regression

No, it isn't

Suggestions

WHY THIS IS PROBLEMATIC

The error message suggests:

  1. Broken installation
  2. Incorrect Flet version
  3. Missing package
  4. Packaging failure

As a result, significant debugging effort was spent investigating:

  1. Flutter assets
  2. pubspec.yaml changes
  3. build artifacts
  4. Flet packaging
  5. version mismatches

...when the actual workaround was simply changing:

ft.ElevatedButton

...to:

ft.Button

ADDITIONAL NOTES

  1. Reproduced on Flet 0.86.3.

  2. Reproduced again after upgrading to:
    Flet 1.0.1
    flet-cli 1.0.1
    flet-desktop 1.0.1
    flet-web 1.0.1

  3. Build completes successfully.

  4. Failure occurs only after launching the generated executable.

Logs

Logs

Traceback (most recent call last):
  File "C:\flutter\extension26\examples\test_extension_26_example\build\site-packages\flet\app.py", line 368, in on_session_created
  File "C:\Users\Nelso\AppData\Local\Temp\serious_python_tempa254e7b5\main.py", line 221, in main
  File "C:\Users\Nelso\AppData\Local\Temp\serious_python_tempa254e7b5\main.py", line 108, in build_canvas_toolbar
  File "C:\flutter\extension26\examples\test_extension_26_example\build\site-packages\flet\__init__.py", line 1818, in __getattr__
AttributeError: module 'flet' has no attribute 'ElevatedButton'

Additional details

While investigating this issue, a significant amount of debugging time was spent distinguishing between:

  1. Runtime packaging issues
  2. Flutter extension issues
  3. Stale generated artifacts
  4. Actual application code defects

For developers working with custom Flet extensions, it is often unclear when a Flutter dependency change requires a full rebuild of generated artifacts.

SUGGESTED IMPROVEMENTS

- Better Detection of Stale Extension Artifacts

When files such as:

pubspec.yaml

...or Flutter extension source files change, it would be helpful if Flet could:

  1. Detect the change automatically.
  2. Warn that cached/generated artifacts may be stale.
  3. Recommend the appropriate cleanup steps.

Example:

Detected changes to Flutter extension dependencies.

A clean rebuild is recommended:

    flutter clean
    flutter pub get
    flet clean

- Add an Official "Deep Clean" Command

Historically, troubleshooting extension issues often involves manually removing build directories.

For example:

build/
.dart_tool/
.flutter-plugins-dependencies

A command such as:

flet clean --deep

...could remove all generated artifacts associated with:

  1. Flutter
  2. Python packaging
  3. Extension packaging

This would eliminate guesswork and make troubleshooting much easier.

- Improved Error Reporting for Packaged Applications

In this case, the runtime error ultimately pointed to:

module 'flet' has no attribute 'ElevatedButton'

However, the actual resolution was replacing a deprecated control with:

ft.Button(...)

The error message caused debugging effort to focus on:

  1. Flutter assets
  2. pubspec.yaml
  3. Build cache corruption
  4. Version mismatches

...rather than the deprecated control itself.

More explicit diagnostics would substantially reduce troubleshooting time.

WHY THIS MATTERS

Flet's extension architecture combines:

  1. Python
  2. Flutter
  3. Dependency packaging
  4. Runtime code generation

When something goes wrong, developers can spend considerable time determining which layer is responsible.

Better cache management, rebuild guidance, and error diagnostics would greatly improve the extension-development experience.

Activity

  1. self-assigned this
    on Sep 27, 2026
  2. ndonkoHenri commented on Sep 27, 2026

    @ndonkoHenri
    Contributor

    Thanks for the detailed report. The error is accurate: the built app contains Flet 1.0.1, which removed ElevatedButton (deprecated since 0.80.0). Line 1818 of flet/__init__.py in your traceback only exists in 1.0.x. Your print(ft.ElevatedButton) check ran against 0.86, where the "will be removed in version 1.0" warning comes from.

    The build got 1.0.1 because your pyproject.toml declares flet>=0.86.x (the template default), and flet build installed the newest flet that allows, not the version in your lock file. From the next release, flet build, flet debug and flet publish pin flet and the official extensions to the CLI's own version. A requirement that rules that version out fails with an explanation, and removed names such as ElevatedButton point to their replacement.

    For now, either migrate (ft.ElevatedButton → ft.Button, ft.app → ft.run), or stay on 0.86 by pinning flet (and any Flet extensions) to your flet-cli version, e.g. flet==0.86.3. On the cache suggestions: stale artifacts weren't involved here, and flet clean already removes the whole build/ directory.

  3. nelson-python commented on Sep 28, 2026

    @nelson-python
    Author

    Hello @ndonkoHenri,

    Thank you for the clarification.

    I now understand that the packaged application installed Flet 1.0.1 because the build process used flet>=0.86.3.

    However, when the issue was first encountered, my local development environment and installed Flet packages were all 0.86.3. The upgrade to 1.0.1 was performed later during troubleshooting after I had already spent a significant amount of time debugging the issue.

    Could you clarify where the flet>=0.86.3 requirement originated from during packaging?

    The reason I'm asking is that, from a developer's perspective, there was no indication that the packaged application would resolve and install a newer major version of Flet than the version installed locally and being used during development.

    In particular, I'm trying to better understand:

    1. Whether the flet>=0.86.3 requirement came from the project template itself.
    2. Whether it was generated from project metadata during packaging.
    3. Whether this behavior is documented somewhere that I may have overlooked.

    Note: You may close this issue as "open in error". Apologies on my end.

    Regards,
    Nelson

  4. ndonkoHenri commented on Oct 11, 2026

    @ndonkoHenri
    Contributor

    Hi @nelson-python, no need to apologize. The report was useful and the questions are fair.

    1. Where flet>=0.86.3 came from: the project template. flet create writes "flet>=<flet-cli version>" into [project].dependencies in pyproject.toml, and the extension template's example app does the same. Your examples/test_extension_26_example is that example app.
    2. What flet build does with it: it reads [project].dependencies (plus [tool.flet.<platform>].dependencies) and uses pip to install them into a fresh site-packages for the target platform. It doesn't look at your local environment or uv.lock. So flet>=0.86.3 resolved to the newest flet on PyPI, 1.0.1, even though everything installed locally was 0.86.3.
    3. Docs: the App dependencies section of the Publish guide lists where dependencies are read from. It doesn't say that version ranges are resolved at build time or that lock files are ignored. You didn't overlook anything; that's a gap on our side.

    A correction to my earlier reply: this change didn't make it into 1.0.2 or 1.0.3. In an upcoming release, flet build, flet debug and flet publish will install flet and the official extensions at the CLI's own version. If a requirement rules that version out, the command will stop and explain why. Accessing a name removed in 1.0, such as ft.ElevatedButton, will tell you its replacement.

    Until then:

    • On 0.86: pin flet==0.86.3, and any Flet extensions to the same version, in pyproject.toml.
    • On 1.0: use ft.Button and ft.run.

    Closing as you suggested. The build change will show up here when its PR is opened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions