繁体   English   中英

如何解决“ ImportError:无法导入名称'printmsg'”

[英]How can I fix “ImportError: cannot import name 'printmsg'”

当使用buildozer构建apk时,我得到的错误归结为调用automake w / o参数的错误:

$ automake
Traceback (most recent call last):
  File "/usr/local/bin/automake", line 11, in <module>
    load_entry_point('automake==0.1.3', 'console_scripts', 'automake')()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2728, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2346, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/local/lib/python3.5/dist-packages/automake/cli.py", line 6, in <module>
    from utils import printmsg
ImportError: cannot import name 'printmsg'

我已经重新安装了automake。 以下是相关版本:

$ sudo pip install automake
Requirement already satisfied: automake in /usr/local/lib/python3.5/dist-packages (0.1.3)
Requirement already satisfied: click in /usr/local/lib/python3.5/dist-packages (from automake) (7.0)
Requirement already satisfied: watchdog in /usr/local/lib/python3.5/dist-packages (from automake) (0.9.0)
Requirement already satisfied: PyYAML>=3.10 in /usr/local/lib/python3.5/dist-packages (from watchdog->automake) (3.13)
Requirement already satisfied: argh>=0.24.1 in /usr/local/lib/python3.5/dist-packages (from watchdog->automake) (0.26.2)
Requirement already satisfied: pathtools>=0.1.1 in /usr/local/lib/python3.5/dist-packages (from watchdog->automake) (0.1.2)

您正在使用的项目的0.1.3版本已被破坏。 它不能工作,因为它的cli模块假定automake软件包的目录本身位于Python路径上,因此automake.utils可以作为utils导入。

在您的系统上,没有抛出ImportError ,而是from utils import printmsg行在其他地方找到了一个不同的顶级utils模块。 无论找到什么内容或在哪里,都无关紧要,因为它不是正确的模块。

作者确实对此问题进行了部分修复,但他们这样做时显然错过了automake/cli.py文件。 您可以手动修复它(将from utils替换from utils /usr/local/lib/python3.5/dist-packages/automake/cli.py from .utils )。

如果您正在寻找GNU automake工具 ,那么您就不需要这个Python项目。 鉴于您正在构建Kivy APK, 几乎可以肯定 ,您正在寻找GNU项目,而不是这个项目。

automake Python项目提出问题后,作者同意他们选择的名称可能会引起冲突,因此将其从PyPI中删除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM