Skip to content

bug: flet test fails with ModuleNotFoundError: No module named 'pydantic_core._pydantic_core' #7022

Open

Description

@ndonkoHenri

Discussed in #7020

Originally posted by jules-baratoux October 28, 2026

Question

Hi,

I'm trying to run flet test, but the app fails to render not able to import Pydantic:

image

I'm not sure what I'm doing wrong. Is there something else I need to configure to make flet test work correctly on Windows when depending on pydantic?

Any help would be appreciated. Thanks!

Configuration

I tried adding the following configuration to my pyproject.toml, but it didn't solve the issue even after a prior flet clean:

[[tool.uv.index]]
name = "flet"
url = "https://pypi.flet.dev"
explicit = true

[tool.uv.sources]
pydantic-core = { index = "flet" }

Error message

File ".../site-packages/pydantic/version.py", line 7, in <module>
File ".../site-packages/pydantic_core/__init__.py", line 8, in <module>
ModuleNotFoundError: No module named 'pydantic_core._pydantic_core'

Note

Also, is there a way to capture the app log (not the test log) when running flet test? I had to rely on a sleep to read the error 😅

async def test_example(flet_app: ftt.FletTestApp):
    await sleep(15)  # Wait to be able to read the app error
    assert False

Activity

  1. self-assigned this
    on Oct 28, 2026
  2. jules-baratoux commented on Oct 28, 2026

    @jules-baratoux

    Thank you so much!

    This was on 1.0.5 from Windows.

    uvx --with flet-cli==1.0.5 flet create .
    uv add pydantic==2.14.1
    uv run flet test

    The version of pydantic seems to matter.

    Code

    Content of src/main.py

    import flet as ft
    
    
    def main(page: ft.Page):
        from pydantic import Field
        Field(eq=0)
    
    
    if __name__ == "__main__":
        ft.run(main)

    Content of tests/test_main.py

    import flet.testing as ftt
    
    from asyncio import sleep
    
    
    async def test_increment(flet_app: ftt.FletTestApp):
        await sleep(15)
        assert False

    More information

    $ uv tree --package pydantic
    Resolved 82 packages in 1ms
    pydantic v2.14.1
    ├── annotated-types v0.8.0
    ├── pydantic-core v2.50.1
    │   └── typing-extensions v4.16.0
    ├── typing-extensions v4.16.0
    └── typing-inspection v0.4.4
        └── typing-extensions v4.16.0

    I don't see pydantic-core v2.50.1 in https://pypi.flet.dev/pydantic_core/

  3. ndonkoHenri commented on Oct 29, 2026

    @ndonkoHenri
    ContributorAuthor

    Thanks, this matches what I reproduced: same Flet 1.0.5, same pydantic 2.14.1 / pydantic-core 2.50.1, same error.

    The pydantic version shouldn't matter on Windows: flet test builds the app in Flutter's Debug mode, and on Windows that embeds a debug build of Python, which can only load compiled modules named *_d.pyd. The pydantic-core wheel from PyPI is installed correctly, but its .pyd is the regular release build, so the debug Python never loads it. Any package with compiled code fails the same way. If an older version worked for you, was it pydantic 1.x? It can run without its compiled module.

    pypi.flet.dev only hosts Android and iOS wheels, so it isn't involved here. Windows uses the wheels from PyPI, and flet build already adds pypi.flet.dev for mobile builds. For Android or iOS you'd currently need pydantic==2.13.4, the newest release whose pydantic-core has mobile wheels there.

    Fixes:

  4. jules-baratoux commented on Oct 29, 2026

    @jules-baratoux

    Thank you again for your prompt help and explanations. Unfortunately, I'm afraid I don't remember which version worked last night while I was trying to pin down the issue for reproduction.

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