我正在尝试使用Buildozer构建应用程序。在主代码中,导入functools。代码在电脑上运行正常,但当我尝试在安卓上运行它时,我得到了NameError: name 'functools' is not defined
我尝试将其添加到buildozer.spec要求中,但产生了不同的错误:
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.在日志中,我可以看到buildozer正在尝试安装functools,但据我所知,它已经安装了/usr/lib64/python3.7/functools.py,并且可以导入。
有谁能告诉我到底是怎么回事?
编辑:我查看了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发布于 2020-07-24 20:43:47
在Ayaan的帮助下我找到了解决方法。正如他提到的,我正在使用Python 3,同时尝试使用为Python 2设计的代码片段
正确的更改是reduce() -> functools.reduce()和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))])发布于 2020-07-23 16:50:17
我认为您的python版本与您编写的代码不匹配。你写的代码可以在其他版本中工作,但不能在你正在使用的版本中工作。
https://stackoverflow.com/questions/63035511
复制相似问题