Buildozer Module not found... HELP

164 views
Skip to first unread message

Jason Watkins

unread,
Aug 8, 2023, 9:28:13 AM8/8/23
to Kivy users support
Hi, I'm having issues with compiling my existing code to work in BUILDOZER. I've need to import the library pysftp but compiling fails with the error 'ModuleNotFoundError: No module named 'cryptography'. I've tried adding cryptography to buildozer.spec's Application requirements but no luck.
Any ideas?
Thanks

Robert

unread,
Aug 8, 2023, 12:58:26 PM8/8/23
to Kivy users support
> but compiling fails with the error 'ModuleNotFoundError: No module named 'cryptography'
I assume you mean running the app.

Not sufficient information here to make a suggestion.

You could look at the build log to see if cryptography is included.
And check there is no user file management issue.

Jason Watkins

unread,
Aug 8, 2023, 5:23:11 PM8/8/23
to Kivy users support
Hi, The buildozer.spec has the entry "requirements = python3,kivy,datetime,plyer,kivymd==0.104.1,pillow,ecdsa,paramiko,cryptography" . Thanks

below is the build logs-

# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Search for Git (git)
#  -> found at /usr/bin/git
# Search for Cython (cython)
#  -> found at /home/user1/.local/bin/cython
# Search for Java compiler (javac)
#  -> found at /usr/lib/jvm/java-17-openjdk-amd64/bin/javac
# Search for Java keytool (keytool)
#  -> found at /usr/lib/jvm/java-17-openjdk-amd64/bin/keytool
# Install platform
# Run ['git', 'config', '--get', 'remote.origin.url']
# Cwd /home/user1/python_android_compile/.buildozer/android/platform/python-for-android
https://github.com/kivy/python-for-android.git
# Run ['git', 'branch', '-vv']
# Cwd /home/user1/python_android_compile/.buildozer/android/platform/python-for-android
* master 0daa74c8 [origin/master] Merge pull request #2796 from misl6/release-2023.05.21
# Run ['/usr/bin/python3', '-m', 'pip', 'install', '-q', '--user', 'appdirs', 'colorama>=0.3.3', 'jinja2', 'sh>=1.10, <2.0; sys_platform!="nt"', 'pep517', 'toml', 'packaging']
# Cwd None
# Apache ANT found at /home/user1/.buildozer/android/platform/apache-ant-1.9.4
# Android SDK found at /home/user1/.buildozer/android/platform/android-sdk
# Recommended android's NDK version by p4a is: 25b
# Android NDK found at /home/user1/.buildozer/android/platform/android-ndk-r25b
# Run ['/usr/bin/python3', '-m', 'pythonforandroid.toolchain', 'aab', '-h', '--color=always', '--storage-dir=/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a', '--ndk-api=21', '--ignore-setup-py', '--debug']
# Cwd /home/user1/python_android_compile/.buildozer/android/platform/python-for-android
usage: toolchain.py aab [-h] [--debug] [--color {always,never,auto}]
                        [--sdk-dir SDK_DIR] [--ndk-dir NDK_DIR]
                        [--android-api ANDROID_API]
                        [--ndk-version NDK_VERSION] [--ndk-api NDK_API]
                        [--symlink-bootstrap-files]
                        [--storage-dir STORAGE_DIR] [--arch ARCH]
                        [--dist-name DIST_NAME] [--requirements REQUIREMENTS]
                        [--recipe-blacklist RECIPE_BLACKLIST]
                        [--blacklist-requirements BLACKLIST_REQUIREMENTS]
                        [--bootstrap BOOTSTRAP] [--hook HOOK] [--force-build]
                        [--no-force-build] [--require-perfect-match]
                        [--no-require-perfect-match] [--allow-replace-dist]
                        [--no-allow-replace-dist]
                        [--local-recipes LOCAL_RECIPES]
                        [--activity-class-name ACTIVITY_CLASS_NAME]
                        [--service-class-name SERVICE_CLASS_NAME]
                        [--java-build-tool {auto,ant,gradle}] [--copy-libs]
                        [--no-copy-libs] [--add-asset ASSETS]
                        [--add-resource RESOURCES] [--private PRIVATE]
                        [--use-setup-py] [--ignore-setup-py] [--release]
                        [--with-debug-symbols] [--keystore KEYSTORE]
                        [--signkey SIGNKEY] [--keystorepw KEYSTOREPW]
                        [--signkeypw SIGNKEYPW]

options:
  -h, --help            show this help message and exit
  --debug               Display debug output and all build info
  --color {always,never,auto}
                        Enable or disable color output (default enabled on
                        tty)
  --sdk-dir SDK_DIR, --sdk_dir SDK_DIR
                        The filepath where the Android SDK is installed
  --ndk-dir NDK_DIR, --ndk_dir NDK_DIR
                        The filepath where the Android NDK is installed
  --android-api ANDROID_API, --android_api ANDROID_API
                        The Android API level to build against defaults to 33
                        if not specified.
  --ndk-version NDK_VERSION, --ndk_version NDK_VERSION
                        DEPRECATED: the NDK version is now found automatically
                        or not at all.
  --ndk-api NDK_API     The Android API level to compile against. This should
                        be your *minimal supported* API, not normally the same
                        as your --android-api. Defaults to min(ANDROID_API,
                        21) if not specified.
  --symlink-bootstrap-files, --ssymlink_bootstrap_files
                        If True, symlinks the bootstrap files creation. This
                        is useful for development only, it could also cause
                        weird problems.
  --storage-dir STORAGE_DIR
                        Primary storage directory for downloads and builds
                        (default: /home/user1/.local/share/python-for-
                        android)
  --arch ARCH           The archs to build for.
  --dist-name DIST_NAME, --dist_name DIST_NAME
                        The name of the distribution to use or create
  --requirements REQUIREMENTS
                        Dependencies of your app, should be recipe names or
                        Python modules. NOT NECESSARY if you are using Python
                        3 with --use-setup-py
  --recipe-blacklist RECIPE_BLACKLIST
                        Blacklist an internal recipe from use. Allows
                        disabling Python 3 core modules to save size
  --blacklist-requirements BLACKLIST_REQUIREMENTS
                        Blacklist an internal recipe from use. Allows
                        disabling Python 3 core modules to save size
  --bootstrap BOOTSTRAP
                        The bootstrap to build with. Leave unset to choose
                        automatically.
  --hook HOOK           Filename to a module that contains python-for-android
                        hooks
  --local-recipes LOCAL_RECIPES, --local_recipes LOCAL_RECIPES
                        Directory to look for local recipes
  --activity-class-name ACTIVITY_CLASS_NAME
                        The full java class name of the main activity
  --service-class-name SERVICE_CLASS_NAME
                        Full java package name of the PythonService class
  --java-build-tool {auto,ant,gradle}
                        The java build tool to use when packaging the APK,
                        defaults to automatically selecting an appropriate
                        tool.
  --add-asset ASSETS    Put this in the assets folder in the apk.
  --add-resource RESOURCES
                        Put this in the res folder in the apk.
  --private PRIVATE     the directory with the app source code files
                        (containing your main.py entrypoint)
  --use-setup-py        Process the setup.py of a project if present.
                        (Experimental!
  --ignore-setup-py     Don't run the setup.py of a project if present. This
                        may be required if the setup.py is not designed to
                        work inside p4a (e.g. by installing dependencies that
                        won't work or aren't desired on Android
  --release             Build your app as a non-debug release build. (Disables
                        gdb debugging among other things)
  --with-debug-symbols  Will keep debug symbols from `.so` files.
  --keystore KEYSTORE   Keystore for JAR signing key, will use jarsigner
                        default if not specified (release build only)
  --signkey SIGNKEY     Key alias to sign PARSER_APK. with (release build
                        only)
  --keystorepw KEYSTOREPW
                        Password for keystore
  --signkeypw SIGNKEYPW
                        Password for key alias

  Whether to force compilation of a new distribution

  --force-build
  --no-force-build      (this is the default)
  --require-perfect-match
  --no-require-perfect-match
                        (this is the default)
  --allow-replace-dist  (this is the default)
  --no-allow-replace-dist
  --copy-libs
  --no-copy-libs        (this is the default)
# Check application requirements
# Compile platform
# Run ['/usr/bin/python3', '-m', 'pythonforandroid.toolchain', 'create', '--dist_name=myapp', '--bootstrap=sdl2', '--requirements=python3,kivy,datetime,plyer,kivymd==0.104.1,pillow,ecdsa,paramiko,cryptography', '--arch=arm64-v8a', '--arch=armeabi-v7a', '--copy-libs', '--color=always', '--storage-dir=/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a', '--ndk-api=21', '--ignore-setup-py', '--debug']
# Cwd /home/user1/python_android_compile/.buildozer/android/platform/python-for-android
# Command failed: ['/usr/bin/python3', '-m', 'pythonforandroid.toolchain', 'create', '--dist_name=myapp', '--bootstrap=sdl2', '--requirements=python3,kivy,datetime,plyer,kivymd==0.104.1,pillow,ecdsa,paramiko,cryptography', '--arch=arm64-v8a', '--arch=armeabi-v7a', '--copy-libs', '--color=always', '--storage-dir=/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a', '--ndk-api=21', '--ignore-setup-py', '--debug']
# ENVIRONMENT:
#     SHELL = '/bin/bash'
#     SESSION_MANAGER = 'local/user1-ThinkPad-X270:@/tmp/.ICE-unix/4533,unix/user1-ThinkPad-X270:/tmp/.ICE-unix/4533'
#     WINDOWID = '0'
#     QT_ACCESSIBILITY = '1'
#     COLORTERM = 'truecolor'
#     XDG_CONFIG_DIRS = '/etc/xdg/xdg-ubuntu:/etc/xdg'
#     SSH_AGENT_LAUNCHER = 'openssh'
#     XDG_MENU_PREFIX = 'gnome-'
#     GNOME_DESKTOP_SESSION_ID = 'this-is-deprecated'
#     LANGUAGE = 'en_GB:en'
#     GNOME_SHELL_SESSION_MODE = 'ubuntu'
#     SSH_AUTH_SOCK = '/run/user/1000/keyring/ssh'
#     XMODIFIERS = '@im=ibus'
#     DESKTOP_SESSION = 'ubuntu'
#     GTK_MODULES = 'gail:atk-bridge'
#     PWD = '/home/user1/python_android_compile'
#     XDG_SESSION_DESKTOP = 'ubuntu'
#     LOGNAME = 'user1'
#     XDG_SESSION_TYPE = 'wayland'
#     SYSTEMD_EXEC_PID = '4560'
#     XAUTHORITY = '/run/user/1000/.mutter-Xwaylandauth.QEDM91'
#     PICO_EXTRAS_PATH = '/home/user1/pico/pico-extras'
#     GJS_DEBUG_TOPICS = 'JS ERROR;JS LOG'
#     PICO_SDK_PATH = '/home/user1/pico/pico-sdk'
#     HOME = '/home/user1'
#     USERNAME = 'user1'
#     IM_CONFIG_PHASE = '1'
#     LANG = 'en_GB.UTF-8'
#     LS_COLORS = 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:'
#     XDG_CURRENT_DESKTOP = 'ubuntu:GNOME'
#     WAYLAND_DISPLAY = 'wayland-0'
#     INVOCATION_ID = '40702cfa48db40bd9576d5970f49699f'
#     MANAGERPID = '4336'
#     PICO_PLAYGROUND_PATH = '/home/user1/pico/pico-playground'
#     GJS_DEBUG_OUTPUT = 'stderr'
#     GNOME_SETUP_DISPLAY = ':1'
#     LESSCLOSE = '/usr/bin/lesspipe %s %s'
#     XDG_SESSION_CLASS = 'user'
#     TERM = 'xterm-256color'
#     LESSOPEN = '| /usr/bin/lesspipe %s'
#     USER = 'user1'
#     COLORFGBG = '15;0'
#     DISPLAY = ':0'
#     SHLVL = '1'
#     PICO_EXAMPLES_PATH = '/home/user1/pico/pico-examples'
#     QT_IM_MODULE = 'ibus'
#     XDG_RUNTIME_DIR = '/run/user/1000'
#     DEBUGINFOD_URLS = 'https://debuginfod.ubuntu.com '
#     JOURNAL_STREAM = '8:44940'
#     XDG_DATA_DIRS = '/usr/share/ubuntu:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop'
#     PATH = '/home/user1/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/user1/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin:/home/user1/workspace/cc65/bin:/home/user1/workspace/x16emu_linux-r38:/home/user1/.local/bin/'
#     GDMSESSION = 'ubuntu'
#     DBUS_SESSION_BUS_ADDRESS = 'unix:path=/run/user/1000/bus'
#     GIO_LAUNCHED_DESKTOP_FILE_PID = '5920'
#     GIO_LAUNCHED_DESKTOP_FILE = '/usr/share/applications/qterminal.desktop'
#     OLDPWD = '/home/user1/python_android_compile/bin'
#     _ = '/home/user1/.local/bin/buildozer'
#     PACKAGES_PATH = '/home/user1/.buildozer/android/packages'
#     ANDROIDSDK = '/home/user1/.buildozer/android/platform/android-sdk'
#     ANDROIDNDK = '/home/user1/.buildozer/android/platform/android-ndk-r25b'
#     ANDROIDAPI = '31'
#     ANDROIDMINAPI = '21'
#
# Buildozer failed to execute the last command
# The error might be hidden in the log above this error
# Please read the full log, and search for it before
# raising an issue with buildozer itself.
# In case of a bug report, please add a full log with log_level = 2

Robert

unread,
Aug 8, 2023, 7:12:59 PM8/8/23
to Kivy users support
So " but no luck. " means some completely different error, who would have guessed?

It is not clear what the issue is, I can only guess that you corrupted buildozer.spec
See the last part of this https://github.com/Android-for-Python/Android-for-Python-Users#changing-buildozerspec

I have no other suggestion.

Jason Watkins

unread,
Aug 9, 2023, 6:19:46 AM8/9/23
to Kivy users support

Hi, Very useful link, thanks. I've set the library requirements to "requirements = python3,kivy,datetime,kivymd,pillow,paramiko==1.17,pysftp==0.2.9"

There seems to be a conflict when I run the following -> pipdeptree -p pysftp

Warning!!! Possibly conflicting dependencies found:
* PyNaCl==1.5.0
 - cffi [required: >=1.4.1, installed: ?]
------------------------------------------------------------------------
pysftp==0.2.9
└── paramiko [required: >=1.17, installed: 2.10.4]






When I launch the app it closes immediately.
When I run "adb -s 192.168.1.99:5555 logcat *:S python:D"  I get the following logs with -> No module named 'cryptography'

08-09 10:58:43.198 25930 25970 I python  : Android kivy bootstrap done. __name__ is __main__
08-09 10:58:43.199 25930 25970 I python  : AND: Ran string
08-09 10:58:43.199 25930 25970 I python  : Run user program, change dir and execute entrypoint
08-09 10:58:43.382 25930 25970 I python  : Traceback (most recent call last):
08-09 10:58:43.382 25930 25970 I python  :   File "/home/user1/python_android_compile/.buildozer/android/app/main.py", line 25, in <module>
08-09 10:58:43.382 25930 25970 I python  :   File "/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/pysftp/__init__.py", line 12, in <module>
08-09 10:58:43.383 25930 25970 I python  :   File "/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/paramiko/__init__.py", line 22, in <module>
08-09 10:58:43.383 25930 25970 I python  :   File "/home/user1/python_android_compile/.buildozer/android/platform/build-arm64-v8a_armeabi-v7a/build/python-installs/myapp/arm64-v8a/paramiko/transport.py", line 33, in <module>
08-09 10:58:43.384 25930 25970 I python  : ModuleNotFoundError: No module named 'cryptography'
08-09 10:58:43.384 25930 25970 I python  : Python for android ended.

Robert

unread,
Aug 9, 2023, 1:05:56 PM8/9/23
to Kivy users support
There seem to be three things going on here, and we should disentangle them.
And if possible address them one at a time...

- Cryptography was in the previous build log, but this run log says it is not there, is that correct?

- A warning about the desktop site packages conflict - I think that is irrelevant to the Android site-packages.

- A listing of the dependencies of pysftp - I have no particular knowledge about this package.

Jason Watkins

unread,
Aug 10, 2023, 12:35:23 PM8/10/23
to Kivy users support
Hi, I looked at the example on https://groups.google.com/g/kivy-users/c/1tWnZHDQuOs   and I am even still having the same issue with their python code and their bulldoser.spec fix. The compiled app on the phone terminates immediately and the phone logs show "08-10 16:38:16.145  1114  1212 I python  :  ModuleNotFoundError: No module named 'cryptography'" . Do you know of any SFTP libraries that should work OK on android?

Thanks

Robert

unread,
Aug 10, 2023, 1:19:38 PM8/10/23
to Kivy users support
I don't know anything about sftp libraries.
Though you might research if that is OK with Google, they tend to block protocols they don't like - just a possibility.

Adding cryptography should build and run, it is built in https://github.com/Android-for-Python/Android-for-Python-Users#if-buildozer-fails-to-compile
Reply all
Reply to author
Forward
0 new messages