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

flet==0.25.0.dev3673 matplotlib error on iphone #4319

Open
1 task done
InesaFitsner opened this issue Nov 6, 2024 · 0 comments
Open
1 task done

flet==0.25.0.dev3673 matplotlib error on iphone #4319

InesaFitsner opened this issue Nov 6, 2024 · 0 comments
Assignees
Labels
bug Something isn't working packaging Related to app packaging platform: ios Specific related to iOS

Comments

@InesaFitsner
Copy link
Contributor

Duplicate Check

Describe the bug

Error displayed on iphone after running basic test:

matplotlib: test_basic - error: dlopen(/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/9648609F-2B5A-4494-9196-1A12FB5EE5FC/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/9648609F-2B5A-4494-9196-1A12FB5EE5FC/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/9648609F-2B5A-4494-9196-1A12FB5EE5FC/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/9648609F-2B5A-4494-9196-1A12FB5EE5FC/Runner.app/Frameworks/libjpeg.62.dylib' (no such file), '/Users/inesa/Library/Developer/CoreSimulator/Devices/D3463E8E-AC7A-45B1-82A6-B0E989B29132/data/Containers/Bundle/Application/9648609F-2B5A-4494-9196-1A12FB5EE5FC/

Code sample

Code
import io

import flet as ft

# from os.path import dirname, join


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

    def matplotlib_tests(e):
        def test_basic():
            try:
                import matplotlib

                page.add(ft.Text("import matplotlib: OK"))

                from flet.matplotlib_chart import MatplotlibChart

                import matplotlib.pyplot as plt

                matplotlib.use("svg")
                fig, ax = plt.subplots()
                fruits = ["apple", "blueberry", "cherry", "orange"]
                counts = [40, 100, 30, 55]
                bar_labels = ["red", "blue", "_red", "orange"]
                bar_colors = ["tab:red", "tab:blue", "tab:red", "tab:orange"]
                ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
                ax.set_ylabel("fruit supply")
                ax.set_title("Fruit supply by kind and color")
                ax.legend(title="Fruit color")
                page.add(MatplotlibChart(fig, expand=True))
                plt.figure()
                plt.plot([1, 2])
                bio = io.BytesIO()
                plt.savefig(bio, format="png")
                b = bio.getvalue()
                EXPECTED_LEN = 16782
                assert len(b) > int(EXPECTED_LEN * 0.8)
                assert len(b) < int(EXPECTED_LEN * 1.2)
                assert b[:24] == (
                    b"\x89PNG\r\n\x1a\n"
                    + b"\x00\x00\x00\rIHDR"  # File header
                    + b"\x00\x00\x02\x80"  # Header chunk header
                    + b"\x00\x00\x01\xe0"  # Width 640  # Height 480
                )

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

        test_basic()

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


ft.app(main)

pyproject.toml:

[project]

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

[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 matplotlib tests" button

Expected behavior

Expected to see matplotlib chart and 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

@ndonkoHenri ndonkoHenri added packaging Related to app packaging platform: ios Specific related to iOS bug Something isn't working labels Nov 7, 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 packaging Related to app packaging platform: ios Specific related to iOS
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants