Skip to content

flet==0.25.0.dev3673 pillow error on iphone  #4320

Open
@InesaFitsner

Description

@InesaFitsner

Duplicate Check

Describe the bug

Error displayed on iphone after running basic test:

pillow: test_basic - error: dlopen(/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/85C67079-83FE-4A4E-A815-C5EF02F0012B/Runner.app/Frameworks/PIL._imaging.framework/PIL._imaging, 0x0002): Library not loaded: @rpath/libjpeg.62.dylib
Referenced from: /Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/85C67079-83FE-4A4E-A815-C5EF02F0012B/Runner.app/Frameworks/PIL._imaging.framework/PIL._imaging
Reason: tried: '/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/85C67079-83FE-4A4E-A815-C5EF02F0012B/Runner.app/libjpeg.62.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22A3351/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 18.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libjpeg.62.dylib' (no such file), '/usr/lib/swift/libjpeg.62.dylib' (no such file, not in dyld cache), '/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/85C67079-83FE-4A4E-A815-C5EF02F0012B/Runner.app/Frameworks/libjpeg.62.dylib' (no such file), '/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/85C67079-83FE-4A4E-A815-C5EF02F0012B/Runner.app/Frameworks/libjpeg.62.dylib' (no such file), '/Library/Developer/CoreSimulator/Volumes/iOS_22A3351/Library/

Code sample

Code
import io
from os.path import dirname, join

import flet as ft


def main(page: ft.Page):
    page.title = "Flet libs test"

    def pillow_tests(e):
        def test_basic():
            try:
                from PIL import Image

                img = Image.open(join(dirname(__file__), "mandrill.jpg"))
                assert img.width == 512
                assert img.height == 512

                out_file = io.BytesIO()
                img.save(out_file, "png")
                out_bytes = out_file.getvalue()

                EXPECTED_LEN = 313772
                assert len(out_bytes) > int(EXPECTED_LEN * 0.8)
                # assert len(out_bytes) < int(EXPECTED_LEN * 1.2)

                assert out_bytes[:24] == (
                    b"\x89PNG\r\n\x1a\n"
                    + b"\x00\x00\x00\rIHDR"  # File header
                    + b"\x00\x00\x02\x00"  # Header chunk header
                    + b"\x00\x00\x02\x00"  # Width 512  # Height 512
                )

                page.add(ft.Text("pillow: test_basic - OK"))

            except Exception as e:
                page.add(ft.Text(f"pillow: test_basic - error: {e}", selectable=True))

        def test_font():
            try:
                from PIL import ImageFont

                font = ImageFont.truetype(join(dirname(__file__), "Vera.ttf"), size=20)
                # ont.getsize("Hello") == (51, 19)
                # font.getsize("Hello world") == (112, 19)
                page.add(ft.Text(f"pillow: test_font - OK"))
            except Exception as e:
                page.add(ft.Text(f"pillow: test_font - error: {e}"))

        test_basic()
        test_font()

    page.add(
        ft.SafeArea(
            ft.Column(
                [
                    ft.ElevatedButton("Run Pillow tests", on_click=pillow_tests),
                ]
            )
        )
    )


ft.app(main)

pyproject.toml

[project]

name = "pillow_app"
version = "1.0.0"
description = ""
authors = [{name = "Flet Developer", email = "your@email.com"}]
dependencies = ["flet==0.25.0.dev3673", "pillow"]

[tool.flet]
android.adaptive_icon_background = "#ffffff"

To reproduce

  1. flet build ipa
  2. Set environment variable export SERIOUS_PYTHON_SITE_PACKAGES=[Path-to-site-packages]
  3. in build/flutter folder, flutter run, choose iphone device -> app opens on iphone
  4. On the app click on "Run pillow tests" button

Expected behavior

Expected to see basic test - OK message

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

15

Flet version

flet==0.25.0.dev3673

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackagingRelated to app packagingplatform: iosSpecific related to iOS

    Type

    No type

    Projects

    Status

    🆕 New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions