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

macOS app throws "library load disallowed by system policy" error while loading 3rd-party Python .so modules #4543

Open
1 task done
FeodorFitsner opened this issue Dec 10, 2024 · 4 comments
Assignees

Comments

@FeodorFitsner
Copy link
Contributor

Duplicate Check

Describe the bug

Original report: #4514 (comment)

I got this error when I release it to test flight and test on my mac M4:

  File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/__init__.py", line 6, in <module>
    from ._pydantic_core import (
ImportError: dlopen(/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so, 0x0002): tried: '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so' (code signature in <17D6EF5C-4D71-3E06-912D-5464BC98FC00> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so' (no such file), '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so' (code signature in <17D6EF5C-4D71-3E06-912D-5464BC98FC00> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/__pypackages__/pydantic_core/_pydantic_core.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy)

Code sample

Code
# n/a

To reproduce

n/a

Expected behavior

No response

Screenshots / Videos

Captures

[Upload media here]

Operating System

macOS

Operating system details

Any version

Flet version

0.25.1

Regression

No, it isn't

Suggestions

No response

Logs

Logs
[Paste your logs here]

Additional details

No response

@dsx1986
Copy link

dsx1986 commented Dec 10, 2024

I do build with entitlements: flet build macos --info-plist LSApplicationCategoryType="public.app-category.productivity" --macos-entitlements com.apple.security.app-sandbox=True --build-number $(date +%y%m%d%H%M)

@FeodorFitsner
Copy link
Contributor Author

OK, as it's sandbox my guess would be #2 from here: " it could be a problem with signing 3rd-party python packages (like pydantic) unpacked during the first run."

Will investigate.

@FeodorFitsner
Copy link
Contributor Author

Note to developers: https://docs.flutter.dev/deployment/macos

@dsx1986
Copy link

dsx1986 commented Dec 13, 2024

I got another one, it is : .cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy. It also relates to numpy. I tried this solution(flet-dev/serious-python#85 (comment)), but did not work.

Traceback (most recent call last):
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/init.py", line 24, in
from . import multiarray
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/multiarray.py", line 10, in
from . import overrides
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/overrides.py", line 8, in
from numpy.core._multiarray_umath import (
ImportError: dlopen(/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so, 0x0002): tried: '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (code signature in <4B244C37-40C5-380A-9FCF-3FE515E61AAA> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (no such file), '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (code signature in <4B244C37-40C5-380A-9FCF-3FE515E61AAA> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/init.py", line 130, in
from numpy.config import show as show_config
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/config.py", line 4, in
from numpy.core._multiarray_umath import (
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/init.py", line 50, in
raise ImportError(msg)
ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.12 from "/Applications/diogenesaibutlerflet.app/Contents/MacOS/diogenesaibutlerflet"
  • The NumPy version is: "1.26.4"

and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.

Original error was: dlopen(/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so, 0x0002): tried: '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (code signature in <4B244C37-40C5-380A-9FCF-3FE515E61AAA> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy), '/System/Volumes/Preboot/Cryptexes/OS/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (no such file), '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' (code signature in <4B244C37-40C5-380A-9FCF-3FE515E61AAA> '/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/core/_multiarray_umath.cpython-312-darwin.so' not valid for use in process: library load disallowed by system policy)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 47, in
File "", line 229, in run_module
File "", line 88, in _run_code
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/main.py", line 8, in
from nexa.gguf import NexaTextInference
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/nexa/gguf/init.py", line 3, in
from .nexa_inference_vlm import NexaVLMInference
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/nexa/gguf/nexa_inference_vlm.py", line 22, in
from nexa.gguf.llama.llama_chat_format import (
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/nexa/gguf/llama/llama_chat_format.py", line 28, in
import numpy as np
File "/Users/simon/Library/Containers/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/Data/Library/Application Support/com.diogenes.ai.chatbot.flet.diogenesaibutlerflet/flet/app/pypackages/numpy/init.py", line 135, in
raise ImportError(msg) from e
ImportError: Error importing numpy: you should not try to import numpy from
its source directory; please exit the numpy source tree, and relaunch
your python interpreter from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants