Build failed while trying to install python dependancies :
[INFO]: *** PYTHON PACKAGE / PROJECT INSTALL STAGE ***
[INFO]: The requirements (certifi, gpxpy, oscpy, plyer) don't have recipes, attempting to install them with pip
[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]: -> directory context /home/user/hostcwd/.buildozer/android/platform/build-arm64-v8a/build
stty: 'standard input': Inappropriate ioctl for device
[INFO]: -> running virtualenv --python=python3 venv
Exception in thread background thread for pid 38291:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/user/.local/bin/virtualenv --python=python3 venv
STDOUT:
Traceback (most recent call last):
File "/home/user/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main'
STDERR:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1212, in <module>
main()
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 680, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 212, in build_dist_from_args
args, "ignore_setup_py", False
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 603, in build_recipes
ignore_setup_py=ignore_project_setup_py
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 773, in run_pymodules_install
'venv'
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 863, in next
self.wait()
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/user/.local/bin/virtualenv --python=python3 venv
STDOUT:
Traceback (most recent call last):
File "/home/user/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main'
[INFO]: Postbuilding kivy for arm64-v8a
[INFO]: # Installing pure Python modules
[INFO]: *** PYTHON PACKAGE / PROJECT INSTALL STAGE ***
[INFO]: The requirements (certifi, gpxpy, oscpy, plyer) don't have recipes, attempting to install them with pip
[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.
[INFO]: -> directory context /home/user/hostcwd/.buildozer/android/platform/build-arm64-v8a/build
stty: 'standard input': Inappropriate ioctl for device
[INFO]: -> running virtualenv --python=python3 venv
Exception in thread background thread for pid 38291:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 1540, in wrap
fn(*args, **kwargs)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 2459, in background_thread
handle_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 2157, in fn
return self.command.handle_command_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/user/.local/bin/virtualenv --python=python3 venv
STDOUT:
Traceback (most recent call last):
File "/home/user/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main'
STDERR:
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 1212, in <module>
main()
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/entrypoints.py", line 18, in main
ToolchainCL()
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 680, in __init__
getattr(self, args.subparser_name.replace('-', '_'))(args)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 154, in wrapper_func
build_dist_from_args(ctx, dist, args)
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/toolchain.py", line 212, in build_dist_from_args
args, "ignore_setup_py", False
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 603, in build_recipes
ignore_setup_py=ignore_project_setup_py
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/build.py", line 773, in run_pymodules_install
'venv'
File "/home/user/hostcwd/.buildozer/android/platform/python-for-android/pythonforandroid/logger.py", line 167, in shprint
for line in output:
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 863, in next
self.wait()
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 792, in wait
self.handle_command_exit_code(exit_code)
File "/home/user/.local/lib/python3.6/site-packages/sh.py", line 815, in handle_command_exit_code
raise exc
sh.ErrorReturnCode_1:
RAN: /home/user/.local/bin/virtualenv --python=python3 venv
STDOUT:
Traceback (most recent call last):
File "/home/user/.local/bin/virtualenv", line 7, in <module>
from virtualenv import main
ImportError: cannot import name 'main'
STDERR:
# Command failed: /usr/bin/python3 -m pythonforandroid.toolchain create --dist_name=ohmy --bootstrap=sdl2 --requirements=plyer,kivy,requests,openssl,certifi,gpxpy,oscpy,android --arch arm64-v8a --copy-libs --color=always --storage-dir="/home/user/hostcwd/.buildozer/android/platform/build-arm64-v8a" --ndk-api=26
# ENVIRONMENT:
# PATH = '/home/user/.buildozer/android/platform/apache-ant-1.9.4/bin:/home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
# HOSTNAME = '5755fc8b672b'
# P4A_RELEASE_KEYSTORE = '/home/user/hostcwd/google_keystore.jks'
# P4A_RELEASE_KEYSTORE_PASSWD = 'xxxx'
# P4A_RELEASE_KEYALIAS_PASSWD = 'xxxx'
# P4A_RELEASE_KEYALIAS = 'ohmy'
# USER = 'user'
# HOME_DIR = '/home/user'
# WORK_DIR = '/home/user/hostcwd'
# SRC_DIR = '/home/user/src'
# LANG = 'en_US.UTF-8'
# LANGUAGE = 'en_US.UTF-8'
# LC_ALL = 'en_US.UTF-8'
# HOME = '/home/user'
# PACKAGES_PATH = '/home/user/.buildozer/android/packages'
# ANDROIDSDK = '/home/user/.buildozer/android/platform/android-sdk'
# ANDROIDNDK = '/home/user/.buildozer/android/platform/android-ndk-r19b'
# ANDROIDAPI = '29'
# ANDROIDMINAPI = '26'
#
# 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
Thanks @brvier for reproducing the bug with docker in master. I'll try to look into it this week
Wheels dependancy seems missing in the Dockerfile too :)
p4a.fork = kivy
p4a.branch = release-2020.04.01
Same error using older p4a repository, so probably not related to p4a changes :)
EDIT : oups i believe it was YYYY-DD-MM ... so that the newer not the older :)
Hi,
I got the same problem, after cloning buildozer repo's I was able to fix by changing the Dockerfile at line 78
As @brvier said, wheel was missing so I add it and I upgrade virtualenv
...
RUN pip3 install --user wheel Cython==0.28.6 ${SRC_DIR}
RUN python3 -m pip install -U pip virtualenv
...
The first one add wheel, the command will failed at the end because of 'bdist_wheel' error
The second will apply previous change without failing and will upgrade virtualenv
After building it I was able to create my apk !
Hope it will help you
PS: @AndreMiras Isn't it possible to make tag on Docker hub ? So we could just pull the previous image and use it to compile ? For eg in this case, even if I used a previous commit to build, it still crash because it was a venv dep's problem, so have a "fixed" image may help ?
I also get the same error for python 2.7 (compiling Pillow)
Opening another pull request for python2.7
I confirm the workaround.
Hello,
I tried using android runtime permissions, as suggested by @AndreMiras, but buildozer logcat still returns the error message:
from virtualenv import main ImportError: cannot import name 'main'
Buildozer.spec :
requirements: python3, kivy, pyjnius
android.add_aars = support-compat-27.0.0.aar
main.py
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from permissions.location import check_permission, ask_permission
class ExampleRoot(BoxLayout):
def check_fine_location_permission(self):
check_permission("android.permission.ACCESS_FINE_LOCATION")
def request_fine_location_permission(self):
ask_permission("android.permission.ACCESS_FINE_LOCATION")
class ExampleApp(App):
def build(self):
return ExampleRoot()
if __name__ == '__main__':
ExampleApp().run()
permissions/location.py
from jnius import autoclass
from kivy.logger import Logger
PythonActivity = autoclass("org.kivy.android.PythonActivity").mActivity
Context = autoclass('android.content.Context')
ContextCompat = autoclass('android.support.v4.content.ContextCompat')
def check_permission(permission, activity=PythonActivity):
permission_status = ContextCompat.checkSelfPermission(activity,
permission)
Logger.info(permission_status)
permission_granted = 0 == permission_status
Logger.info("Permission Status: {}".format(permission_granted))
return permission_granted
def ask_permission(permission, activity=PythonActivity):
PythonActivity.requestPermissions([permission])
Any suggestion to fix this error?
Thanks a lot
Hi @pasteurjr, are you compiling with buildozer's docker image or by your own installation ?
If you build with docker please pull the latest image
docker pull kivy/buildozer
Then recreate your buildozer's container
If it's your own installation, please update pip and virtual env
pip install --upgrade pip virtualenv
If you have both python3 and python2 installed, be sure to upgrade python3 environment with
python3 -m pip install --upgrade pip virtualenv
Hope this will help you !
Thanks a lot @Sirfanas , it worked for me!
@Sirfanas worked for me as well with Linux subsystem on Windows! Thank you.
Thanks @Sirfanas
When Iโm building Kivy project into android app, I meet such problem:
โโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโ
Ubuntu18.04.4LTS
Python3.6.9(system)
Plz help me
Most helpful comment
Hi @pasteurjr, are you compiling with buildozer's docker image or by your own installation ?
If you build with docker please pull the latest image
Then recreate your buildozer's container
If it's your own installation, please update pip and virtual env
If you have both python3 and python2 installed, be sure to upgrade python3 environment with
Hope this will help you !