ModuleNotFound: No module named 'math'

640 views
Skip to first unread message

Padam Gupta

unread,
Jul 6, 2020, 8:32:52 AM7/6/20
to Kivy users support
Hello Everyone, I was just wondering how can I convert my flask app into a web view android app. I got py4a and give it a try.
After successful installation, I run python-for-android logcat and got this
[WARNING]: $ANDROIDNDKVER is deprecated and no longer necessary, the value you set is ignored
[INFO]:    Found Android API target in $ANDROIDAPI: 28
[ERROR]:   Build failed: Asked to build for armeabi architecture with API 28, but API 21 or greater does not support armeabi.
[INFO]:    Instructions: You probably want to build with --arch=armeabi-v7a instead

I didn't understand what does it mean but I skip this error and use this

p4a apk --private /home/deviantpadam/recommender_system/ --package=deviant.myapp --name "Scholarly Articles Andoid" --version 0.1 --bootstrap=webview --requirements=python==3.7.5,Flask==1.1.1,gensim==3.8.0,h5py==2.10.0,Jinja2==2.11.1,numpy==1.18.1,pandas==1.0.3,SQLAlchemy==1.3.17,pickle5==0.0.10,cloudpickle==1.4.1,scikit-learn==0.22.1,scipy==1.4.1 ,category_encoders==2.2.2,lightgbm==2.3.1 --port=5000 --orientation sensor --debug

Now here is the Log,
[DEBUG]:   
[DEBUG]:    Python build finished successfully!
[DEBUG]:    The necessary bits to build these optional modules were not found:
[DEBUG]:    _dbm                  _gdbm                 _tkinter
[DEBUG]:    nis                   spwd
[DEBUG]:    To find the necessary bits, look in setup.py in detect_modules() for the module's name.
[DEBUG]:   
[DEBUG]:   
[DEBUG]:    The following modules found by detect_modules() in setup.py, have been
[DEBUG]:    built by the Makefile instead, as configured by the Setup files:
[DEBUG]:    _abc                  atexit                pwd
[DEBUG]:    time
[DEBUG]:   
[DEBUG]:   
[DEBUG]:    Failed to build these modules:
[DEBUG]:    _crypt                _curses               _curses_panel
[DEBUG]:    _uuid                 grp                   readline
[DEBUG]:   
[DEBUG]:    running build_scripts
[DEBUG]:    creating build/scripts-3.8
[DEBUG]:    copying and adjusting /home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/Tools/scripts/pydoc3 -> build/scripts-3.8
[DEBUG]:    copying and adjusting /home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/Tools/scripts/idle3 -> build/scripts-3.8
[DEBUG]:    copying and adjusting /home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/Tools/scripts/2to3 -> build/scripts-3.8
[DEBUG]:    changing mode of build/scripts-3.8/pydoc3 from 664 to 775
[DEBUG]:    changing mode of build/scripts-3.8/idle3 from 664 to 775
[DEBUG]:    changing mode of build/scripts-3.8/2to3 from 664 to 775
[DEBUG]:    renaming build/scripts-3.8/pydoc3 to build/scripts-3.8/pydoc3.8
[DEBUG]:    renaming build/scripts-3.8/idle3 to build/scripts-3.8/idle3.8
[DEBUG]:    renaming build/scripts-3.8/2to3 to build/scripts-3.8/2to3-3.8
[INFO]:    <- directory context /home/deviantpadam
[INFO]:    Building genericndkbuild for armeabi-v7a
[INFO]:    -> directory context /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni
[DEBUG]:   -> running ndk-build V=1
[DEBUG]:    Android NDK: Found platform level in /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/project.properties. Setting APP_PLATFORM to android-28.
[DEBUG]:    Android NDK: WARNING:/home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/Android.mk:main: non-system libraries in linker flags: -lpython3.8m
[DEBUG]:    Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES
[DEBUG]:    Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the
[DEBUG]:    Android NDK:     current module
[DEBUG]:    /home/deviantpadam/Documents/android-ndk-r19c/build/core/build-binary.mk:672: Android NDK: Module main depends on undefined modules: python_shared
[DEBUG]:    rm -f /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/libs/armeabi-v7a/*
[DEBUG]:    rm -f /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/libs/armeabi-v7a/gdbserver
[DEBUG]:    rm -f /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/libs/armeabi-v7a/gdb.setup
[DEBUG]:    [armeabi-v7a] Compile thumb  : main <= start.c
[DEBUG]:    rm -f /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/start.o
[DEBUG]:    /usr/bin/ccache /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -MMD -MP -MF /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/start.o.d -target armv7-none-linux-androideabi28 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fpic -mfpu=vfpv3-d16  -march=armv7-a -mthumb -Oz -DNDEBUG  -mfpu=neon -I/home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src   -DANDROID -I/home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/Include -Wa,--noexecstack -Wformat -Werror=format-security  -c  /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/start.c -o /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/start.o
[DEBUG]:    [armeabi-v7a] Compile thumb  : main <= pyjniusjni.c
[DEBUG]:    rm -f /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/pyjniusjni.o
[DEBUG]:    /usr/bin/ccache /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -MMD -MP -MF /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/pyjniusjni.o.d -target armv7-none-linux-androideabi28 -fdata-sections -ffunction-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes  --sysroot /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/sysroot -g -Wno-invalid-command-line-argument -Wno-unused-command-line-argument  -fno-addrsig -fpic -mfpu=vfpv3-d16  -march=armv7-a -mthumb -Oz -DNDEBUG  -mfpu=neon -I/home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src   -DANDROID -I/home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/Include -Wa,--noexecstack -Wformat -Werror=format-security  -c  /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/pyjniusjni.c -o /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/pyjniusjni.o
[DEBUG]:    /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/pyjniusjni.c:15:9: warning: 'LOGI' macro redefined [-Wmacro-redefined]
[DEBUG]:    #define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
[DEBUG]:            ^
[DEBUG]:    /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/pyjniusjni.c:5:9: note: previous definition is here
[DEBUG]:    #define LOGI(...) do {} while (0)
[DEBUG]:            ^
[DEBUG]:    /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/pyjniusjni.c:16:9: warning: 'LOGE' macro redefined [-Wmacro-redefined]
[DEBUG]:    #define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
[DEBUG]:            ^
[DEBUG]:    /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/jni/application/src/pyjniusjni.c:6:9: note: previous definition is here
[DEBUG]:    #define LOGE(...) do {} while (0)
[DEBUG]:            ^
[DEBUG]:    2 warnings generated.
[DEBUG]:    [armeabi-v7a] SharedLibrary  : libmain.so
[DEBUG]:    /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -Wl,-soname,libmain.so -shared /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/start.o /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/objs/main/pyjniusjni.o -lgcc -Wl,--exclude-libs,libgcc.a -latomic -Wl,--exclude-libs,libatomic.a -target armv7-none-linux-androideabi28 -no-canonical-prefixes   -L/home/deviantpadam/.local/share/python-for-android/build/other_builds/python3-libbz2-liblzma/armeabi-v7a__ndk_target_21/python3/android-build -Wl,--build-id -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--warn-shared-textrel -Wl,--fatal-warnings   -llog -lpython3.8m -lc -lm -o /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/libmain.so
[DEBUG]:    [armeabi-v7a] Install        : libmain.so => libs/armeabi-v7a/libmain.so
[DEBUG]:    install -p /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/obj/local/armeabi-v7a/libmain.so /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/libs/armeabi-v7a/libmain.so
[DEBUG]:    /home/deviantpadam/Documents/android-ndk-r19c/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip --strip-unneeded  /home/deviantpadam/.local/share/python-for-android/build/bootstrap_builds/webview/libs/armeabi-v7a/libmain.so
[INFO]:    <- directory context /home/deviantpadam
[INFO]:    Building pytz for armeabi-v7a
[INFO]:    pytz apparently isn't already in site-packages
[INFO]:    Installing pytz into site-packages
[INFO]:    -> directory context /home/deviantpadam/.local/share/python-for-android/build/other_builds/pytz/armeabi-v7a__ndk_target_21/pytz
[DEBUG]:   -> running python3 setup.py install -O2 --root=/home/deviantpadam/.local/share/python-for-android/build/python-installs/unnamed_dist_1 --install-lib=.
[DEBUG]:    Traceback (most recent call last):
[DEBUG]:      File "setup.py", line 5, in <module>
[DEBUG]:        import pytz
[DEBUG]:      File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/pytz/armeabi-v7a__ndk_target_21/pytz/pytz/__init__.py", line 12, in <module>
[DEBUG]:        import datetime
[DEBUG]:      File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/datetime.py", line 8, in <module>
[DEBUG]:        import math as _math
[DEBUG]:    ModuleNotFoundError: No module named 'math'
Exception in thread background thread for pid 24380:
Traceback (most recent call last):
  File "/home/deviantpadam/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/home/deviantpadam/anaconda3/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 1662, in wrap
    fn(*args, **kwargs)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 2606, in background_thread
    handle_exit_code(exit_code)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 2304, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 877, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /home/deviantpadam/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py install -O2 --root=/home/deviantpadam/.local/share/python-for-android/build/python-installs/unnamed_dist_1 --install-lib=.

  STDOUT:
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    import pytz
  File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/pytz/armeabi-v7a__ndk_target_21/pytz/pytz/__init__.py", line 12, in <module>
    import datetime
  File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/datetime.py", line 8, in <module>
    import math as _math
ModuleNotFoundError: No module named 'math'


  STDERR:


Traceback (most recent call last):
  File "/home/deviantpadam/anaconda3/bin/p4a", line 8, in <module>
    sys.exit(main())
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/entrypoints.py", line 18, in main
    ToolchainCL()
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/toolchain.py", line 709, in __init__
    getattr(self, command)(args)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/toolchain.py", line 154, in wrapper_func
    build_dist_from_args(ctx, dist, args)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/toolchain.py", line 216, in build_dist_from_args
    args, "ignore_setup_py", False
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/build.py", line 577, in build_recipes
    recipe.build_arch(arch)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/recipe.py", line 946, in build_arch
    self.install_python_package(arch)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/recipe.py", line 965, in install_python_package
    _env=hpenv, *self.setup_extra_args)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/pythonforandroid/logger.py", line 167, in shprint
    for line in output:
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 925, in next
    self.wait()
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 849, in wait
    self.handle_command_exit_code(exit_code)
  File "/home/deviantpadam/anaconda3/lib/python3.7/site-packages/sh.py", line 877, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_1: 

  RAN: /home/deviantpadam/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3 setup.py install -O2 --root=/home/deviantpadam/.local/share/python-for-android/build/python-installs/unnamed_dist_1 --install-lib=.

  STDOUT:
Traceback (most recent call last):
  File "setup.py", line 5, in <module>
    import pytz
  File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/pytz/armeabi-v7a__ndk_target_21/pytz/pytz/__init__.py", line 12, in <module>
    import datetime
  File "/home/deviantpadam/.local/share/python-for-android/build/other_builds/hostpython3/desktop/hostpython3/Lib/datetime.py", line 8, in <module>
    import math as _math
ModuleNotFoundError: No module named 'math'


  STDERR:


Please help me to get rid of these errors.

K leo

unread,
Jul 6, 2020, 11:45:36 AM7/6/20
to Kivy users support
Check out buildozer.  It's a wrapper around p4a for Android but has easier ways for setting.

Robert Flatt

unread,
Jul 6, 2020, 1:29:29 PM7/6/20
to Kivy users support
Probably several issues, but   scikit-learn==0.22.1,scipy==1.4.1    is fatal, these are not available.
Not gonna work, sorry.
Message has been deleted

Padam Gupta

unread,
Jul 10, 2020, 8:44:37 AM7/10/20
to Kivy users support
Thanks for response.
so should I use lower version of scikit and scipy? If yes, then which version?

Padam Gupta

unread,
Jul 10, 2020, 8:45:53 AM7/10/20
to Kivy users support
Thanks for response.
Using buildozer can I make a web-view android app?

Andrei Sima

unread,
Jul 10, 2020, 8:56:52 AM7/10/20
to Kivy users support
So should I use lower version of scipy and scikit-learn?
None will work. There is no recipe for these packages.
And scipy has pandas as a dependency and things get even more complicated.

Using buildozer can I make a web-view android app?
No. Buildozer is based on python4andoid that is making possible running python on android OS.

____________________
Andrei Sima


--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/26f049f5-d4b3-4cd6-bb73-ec2d36ad6e02o%40googlegroups.com.

Padam Gupta

unread,
Jul 10, 2020, 2:24:23 PM7/10/20
to Kivy users support
Thanks for response.
So there is no way to convert my flask app into android app rather than writing code from scratch ?
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages