首页 > 解决方案 > Buildozer:NameError:未定义名称'functools'

问题描述

我正在尝试使用 Buildozer 构建应用程序。在我正在导入的主代码functools中。该代码在计算机上运行正常,但是当我尝试在 android 上运行它时,我得到了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

标签: pythonpython-3.xbuildozerfunctools

解决方案


我认为您拥有的 python 版本与您编写的代码不匹配。您编写的代码适用于其他版本,但不适用于您正在使用的版本。


推荐阅读