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

numpy/opencv fails with latest p4a at runtime (import) #1678

Closed
zworkb opened this issue Feb 5, 2019 · 3 comments
Closed

numpy/opencv fails with latest p4a at runtime (import) #1678

zworkb opened this issue Feb 5, 2019 · 3 comments

Comments

@zworkb
Copy link
Contributor

zworkb commented Feb 5, 2019

I was very happy to read that the opencv recipe was updated to version 4.0.1 and the build runs fine with python3, numpy and opencv, but when starting the app on android it gives the following error in logcat:

I python  : Traceback (most recent call last):
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/app/main.py", line 1, in <module>
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/numpy/__init__.py", line 142, in <module>
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/numpy/add_newdocs.py", line 13, in <module>
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/numpy/lib/__init__.py", line 8, in <module>
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/numpy/lib/type_check.py", line 11, in <module>
I python  :   File "/home/phil/dev/kivy/cvtest/.buildozer/android/platform/build/build/python-installs/cvtest400/numpy/core/__init__.py", line 26, in <module>

I/python : ImportError: 
I/python : Importing the multiarray numpy extension module failed.  Most
I/python : likely you are trying to import a failed build of numpy.
I/python : If you're working with a numpy git repo, try `git clean -xdf` (removes all
I/python : files not under version control).  Otherwise reinstall numpy.
I/python : Original error was: dlopen failed: library "libpython2.7.so" not found
I/python : Python for android ended.

I ran the build with the master of buildozer and p4a (0c4cd1d) and python 3.5

the requirements in buildozer.spec:

requirements = kivy, android,  numpy

the rest was untouched after buildozer init

in the main.py it fails at:

import numpy as np

I tried that on a device runnning Android 7.0 and another one with Android 5.1.1 with the same results

@AndreMiras
Copy link
Member

In the requirements of your buildozer.spec please add python3

strubbi77 added a commit to strubbi77/python-for-android that referenced this issue Feb 5, 2019
numpy/opencv fails with latest p4a at runtime (import) kivy#1678
@zworkb
Copy link
Contributor Author

zworkb commented Feb 6, 2019

@AndreMiras thanks for the hint. When compiling with the python3 requirement the build fails at compiling pyjnius:

...
jnius/jnius.c: In function '__Pyx_ExceptionSave':
jnius/jnius.c:46818:19: error: 'PyThreadState' has no member named 'exc_type'
     *type = tstate->exc_type;
               ^
jnius/jnius.c:46819:20: error: 'PyThreadState' has no member named 'exc_value'
     *value = tstate->exc_value;
...

I have cython 0.28.2 and tried with python3.5 and 3.7
I also tried pyjnius versions 1.1.2, 1.1.3, 1.2.0
This issue is not related to numpy, it occurs with a bare kivy/p4a project

@zworkb
Copy link
Contributor Author

zworkb commented Feb 7, 2019

the problem was an old system-wide version of cython that interfered with the version installed in the virtualenv i was using, updating to cython 0.29 did the job
Thanks to @Jonast

@zworkb zworkb closed this as completed Feb 7, 2019
inclement pushed a commit that referenced this issue Feb 10, 2019
* update to add dependency on python3 to opencv recipe
numpy/opencv fails with latest p4a at runtime (import) #1678

* Further recipe changes for python3 #1514

* Update __init__.py

Removed unnecessary hostpython*

* Update __init__.py

Removed unnecessary hostpython*

* Update __init__.py

Removed unnecessary python*

* Update __init__.py

Removed unnecessary python*

* Update __init__.py

Removed conflicts because it was wrong

* Update __init__.py
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