簡體   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