kivy-ios icon indicating copy to clipboard operation
kivy-ios copied to clipboard

Numpy (1.20.2) crash in Xcode 12.4 iOS 14.4

Open mamunabcoder opened this issue 4 years ago • 12 comments

Verrsions

Python : 3.9.6 MacOS version : Catalina XCode Version : 12.4 Cython version : 0.29.24

Original error was: dynamic module does not define module export function (PyInit__multiarray_umath)

Numpy found the below crash issues after testing the code based implementation

NPY: test import numpy [INFO ] [Base ] Leaving application in progress... Traceback (most recent call last): File "", line 44, in load_module File "/Users/bjitlimited/Work/JASMY/RnD/kivy_investigation/kivy/kivy-ios/dist/root/python3/lib/python3.9/imp.py", line 342, in load_dynamic File "", line 711, in _load File "", line 666, in _load_unlocked File "", line 565, in module_from_spec File "", line 1108, in create_module File "", line 228, in _call_with_frames_removed ImportError: dynamic module does not define module export function (PyInit_numpy_core__multiarray_umath)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/numpy/core/init.py", line 22, in from . import multiarray File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/numpy/core/multiarray.py", line 12, in from . import overrides File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/numpy/core/overrides.py", line 7, in from numpy.core._multiarray_umath import ( File "", line 48, in load_module File "/Users/bjitlimited/Work/JASMY/RnD/kivy_investigation/kivy/kivy-ios/dist/root/python3/lib/python3.9/imp.py", line 342, in load_dynamic ImportError: dynamic module does not define module export function (PyInit__multiarray_umath)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/Users/bjitlimited/Work/JASMY/RnD/kivy_investigation/kivy/kivy-ios/touchtracer-ios/YourApp/main.py", line 177, in File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/app.py", line 950, in run runTouchApp() File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/base.py", line 582, in runTouchApp EventLoop.mainloop() File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/base.py", line 347, in mainloop self.idle() File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/base.py", line 391, in idle self.dispatch_input() File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/base.py", line 342, in dispatch_input post_dispatch_input(*pop(0)) File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/kivy/base.py", line 301, in post_dispatch_input wid.dispatch('on_touch_move', me) File "kivy/_event.pyx", line 724, in kivy._event.EventDispatcher.dispatch File "/Users/bjitlimited/Work/JASMY/RnD/kivy_investigation/kivy/kivy-ios/touchtracer-ios/YourApp/main.py", line 119, in on_touch_move File "/Users/bjitlimited/Work/JASMY/RnD/kivy_investigation/kivy/kivy-ios/touchtracer-ios/YourApp/main.py", line 60, in test_numpy File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/numpy/init.py", line 145, in from . import core File "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/lib/python3.9/site-packages/numpy/core/init.py", line 48, 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.9 from "/Users/bjitlimited/Library/Developer/CoreSimulator/Devices/E95B7D94-6151-4C75-B8C8-ABBE15F2EFA4/data/Containers/Bundle/Application/0BF443C6-ED85-46AC-98AB-97CA16A4B8B5/touchtracer.app/touchtracer"
  • The NumPy version is: "1.20.2"

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

Original error was: dynamic module does not define module export function (PyInit__multiarray_umath)

2021-09-28 17:26:17.879655+0600 touchtracer[72862:1413341] Application quit abnormally! 2021-09-28 17:26:17.910286+0600 touchtracer[72862:1413341] Leaving

mamunabcoder avatar Sep 29 '21 05:09 mamunabcoder

Got this error too, anyone has got any clues ?

dcentanni avatar Oct 01 '21 15:10 dcentanni

Can you please post a snippet to reproduce it? How did you installed kivy-ios?

misl6 avatar Oct 03 '21 10:10 misl6

Can you please post a snippet to reproduce it? How did you installed kivy-ios?

I have followed approach to install kivy-ios:

brew install autoconf automake libtool pkg-config brew link libtool cd into local app directory () git clone https://github.com/kivy/kivy-ios.git cd kivy-ios/ python3 -m venv venv . venv/bin/activate pip install -e . pip install cython python3 toolchain.py build kivy python3 numpy python3 toolchain.py create open projectname.xcodeproj

After completing above task import numpy then try to build and run the project, application crash

mamunabcoder avatar Oct 04 '21 02:10 mamunabcoder

Same here

Can you please post a snippet to reproduce it? How did you installed kivy-ios?

I have followed approach to install kivy-ios:

brew install autoconf automake libtool pkg-config brew link libtool cd into local app directory () git clone https://github.com/kivy/kivy-ios.git cd kivy-ios/ python3 -m venv venv . venv/bin/activate pip install -e . pip install cython python3 toolchain.py build kivy python3 numpy python3 toolchain.py create open projectname.xcodeproj

After completing above task import numpy then try to build and run the project, application crash

dcentanni avatar Oct 04 '21 08:10 dcentanni

Same problem - little luck. Any one a suggestion?

JohanVDAS avatar Dec 02 '21 16:12 JohanVDAS

Same problem -- any chance it can be looked into?

w3sip avatar Feb 01 '22 22:02 w3sip

Same problem. I find that Python-Apple-support do some extra jobs when integrating Numpy. Does Kivy miss these steps? https://github.com/beeware/Python-Apple-support/blob/3.10/patch/numpy/README.rst

xu-xionglong avatar Feb 07 '22 01:02 xu-xionglong

The problem actually is the Numpy exports get optimized out during linking. Adding -Wl,-force_load,libnumpy.a to the binary linking with Kivy solved it for me.

w3sip avatar Feb 07 '22 02:02 w3sip

The problem actually is the Numpy exports get optimized out during linking. Adding -Wl,-force_load,libnumpy.a to the binary linking with Kivy solved it for me.

I'm also getting this error. @w3sip could you explain more specifically how you solved the issue by adding these parameters to the Kivy binary linking?

coling-git avatar Mar 12 '22 00:03 coling-git

@w3sip How did you solve this issue it has me stumped.

SamB31 avatar Oct 20 '22 15:10 SamB31

Afraid never managed to get it to work. Gave up.

On 20 Oct 2022, at 17:02, SamB31 @.@.>> wrote:

@w3siphttps://github.com/w3sip How did you solve this issue it has me stumped.

— Reply to this email directly, view it on GitHubhttps://github.com/kivy/kivy-ios/issues/647#issuecomment-1285700055, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AWWVOCO7XY2SLGAJI7O7LYTWEFNJTANCNFSM5E7AL2MQ. You are receiving this because you commented.Message ID: @.***>

JohanVDAS avatar Oct 20 '22 17:10 JohanVDAS

The problem actually is the Numpy exports get optimized out during linking. Adding -Wl,-force_load,libnumpy.a to the binary linking with Kivy solved it for me.

I'm also getting this error. @w3sip could you explain more specifically how you solved the issue by adding these parameters to the Kivy binary linking?

In your Xcode project build settings, search for Other linker flags and add -Wl -force_load /path/to/libnumpy.a to it. That did the trick for me.

krs1w avatar May 31 '23 12:05 krs1w