无法使用buildozer构建APK

时间:2020-09-03 09:42:16

标签: python linux ubuntu buildozer

我已经尝试构建APK 3天了。一般来说,我对Linux还是很陌生,并且已经遵循了本教程:https://www.youtube.com/watch?v=kcte8vcGMSU 我按照他的指示进行了所有操作,唯一的区别是我无法像他那样安装kivy,我以另一种方式安装了它,但是它可以工作,并且可以从终端运行main.py。 无论如何,buildozer init可以工作,但是当我尝试使用buildozer android debug时,会弹出此错误:

Traceback (most recent call last):
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 567, in _build_master
    ws.require(__requires__)
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 884, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 775, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (buildozer 0.38.dev0 (/home/rain/.local/lib/python3.8/site-packages), Requirement.parse('buildozer==1.2.0.dev0'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/buildozer", line 33, in <module>
    sys.exit(load_entry_point('buildozer==1.2.0.dev0', 'console_scripts', 'buildozer')())
  File "/home/rain/.local/lib/python3.8/site-packages/buildozer/scripts/client.py", line 13, in main
    Buildozer().run_command(sys.argv[1:])
  File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 1053, in run_command
    targets = [x[0] for x in self.targets()]
  File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 1053, in <listcomp>
    targets = [x[0] for x in self.targets()]
  File "/home/rain/.local/lib/python3.8/site-packages/buildozer/__init__.py", line 944, in targets
    m = __import__('buildozer.targets.{0}'.format(target),
  File "/home/rain/.local/lib/python3.8/site-packages/buildozer/targets/android.py", line 41, in <module>
    from distutils.version import LooseVersion
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "/home/rain/.local/lib/python3.8/site-packages/_distutils_hack/__init__.py", line 83, in create_module
    return importlib.import_module('setuptools._distutils')
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/rain/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 16, in <module>
    import setuptools.version
  File "/home/rain/.local/lib/python3.8/site-packages/setuptools/version.py", line 1, in <module>
    import pkg_resources
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3239, in <module>
    def _initialize_master_working_set():
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3222, in _call_aside
    f(*args, **kwargs)
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3251, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 569, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 582, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/home/rain/.local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 770, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'buildozer==1.2.0.dev0' distribution was not found and is required by the application

对不起,我是新手,我真的很困惑和无助。任何帮助将不胜感激。在VM中使用最新版本的Ubuntu。

1 个答案:

答案 0 :(得分:0)

这可能是因为您使用的是python 3.8 尝试使用python 3.6,并确保不仅安装python3.6,还将主要python版本更改为3.6

如何轻松安装python很容易找到,所以我不再讨论

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 0
sudo update-alternatives --install /usr/bin/python python3 /usr/bin/python3.6 0

最后一个数字0是优先级,如果以上都不起作用,请尝试1或2

这是更改主要python版本的方法