I'm trying to build app with Buildozer. In the main code im importing functools
. The code runs Ok on computer, but when I try to run it on android I get NameError: name 'functools' is not defined
I tried to add it in buildozer.spec
requirements, but that yields in different error:
File "/tmp/pip-install-ef316qvg/functools/functools.py", line 34
raise TypeError, 'compose expects at least one argument'
^
SyntaxError: invalid syntax
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
In the log I can see that buildozer is trying to install the functools
but as far as I can tell it's already installed /usr/lib64/python3.7/functools.py
and can be imported.
Could anyone please give me an idea whats going on?
EDIT: I took a look at functools verzion:
>>> from getversion import get_module_version
>>> import functools
>>> version, details = get_module_version(functools)
>>> print(version)
3.7.7.final.0
>>> print(details)
Version '3.7.7.final.0' found for module 'functools' by strategy 'get_builtin_module_version', after the following failed attempts:
- Attempts for module 'functools':
- <get_module_version_attr>: module 'functools' has no attribute '__version__'
- <get_version_using_pkgresources>: Invalid version number: None
- <get_builtin_module_version>: SUCCESS: 3.7.7.final.0
With help of Ayaan I found the fix. As he mentioned I'm using Python 3, while trying to use code snippet designed for Python 2
The proper change is reduce()
-> functools.reduce()
and map()
-> list(map())
return functools.reduce(lambda a, b: a and b,
[True if p == 0 else False for p in list(map(checkperm, permissions))])