繁体   English   中英

无法安装buildozer

[英]Can't install buildozer

我试图安装一个名为Buildozer的工具,用于将 python kivy 程序编译成 APK。

我用了

pip3 install --user --upgrade buildozer

正如安装指南所说,但发生了错误:

C:\Python3\Scripts>pip install buildozer
Collecting buildozer
  Using cached buildozer-1.4.0-py3-none-any.whl (84 kB)
Collecting sh
  Using cached sh-1.14.3.tar.gz (62 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\Mohamed\AppData\Local\Temp\pip-install-pt7naaa7\sh_21f177c5355f4c0ab5cf85a2821a9137\setup.py", line 5, in <module>
          import sh
        File "C:\Users\Mohamed\AppData\Local\Temp\pip-install-pt7naaa7\sh_21f177c5355f4c0ab5cf85a2821a9137\sh.py", line 37, in <module>
          import fcntl
      ModuleNotFoundError: No module named 'fcntl'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

我尝试安装另一个版本的 python 但没有成功。

如果有人可以帮助我,我将不胜感激。

Windows下不能直接使用Buildozer,可以通过WSL在Windows运行Ubuntu Linux上使用。 官方安装说明可以在这里找到:

https://buildozer.readthedocs.io/en/latest/installation.html

它建议安装 Java 17,但我个人对 JDK 17 有疑问,因此我建议改为安装 JDK 11。

  1. 从 Microsoft Store 安装 Ubuntu 22.04.xx LTS

    https://www.microsoft.com/store/apps/9PN20MSR04DW

  2. 从 Windows 开始菜单或使用 PyCharm 终端运行已安装的 Ubuntu(终端窗口):

    在此处输入图像描述

  3. 通过运行以下命令在 Ubuntu 上安装 Buildozer:

     sudo apt update sudo apt install -y git zip unzip openjdk-11-jdk python3-pip autoconf libtool pkg-config zlib1g-dev libncurses5-dev libncursesw5-dev libtinfo5 cmake libffi-dev libssl-dev pip3 install --user --upgrade Cython==0.29.19 virtualenv echo "export PATH=\$PATH:~/.local/bin/" >> ~/.bashrc pip3 install --user --upgrade buildozer
  4. 现在确保您当前的 Ubuntu 目录设置为您的 Python 项目目录。 例如,如果您的项目存储在: C:\Kivy\Projects\MyHelloWorld ,则将您的 Ubuntu 当前目录更改为/mnt/c/Kivy/Projects/MyHelloWorld

     cd /mnt/c/Kivy/Projects/MyHelloWorld

    注意:使用 PyCharm 终端,它将始终将当前目录设置为项目文件夹

  5. 确保您的 Windows 用户对 Windows 下的项目文件夹具有完全控制访问权限

  6. 在 Ubuntu 终端下为您的项目生成初始buildozer.spec

     buildozer init
  7. 更改 buildozer.spec 行:

     # android.accept_sdk_license = False

     android.accept_sdk_license = True

     #android.api = 27

     android.api = 33
  8. 您可以使用例如以下内容构建您的项目:

     buildozer -v android debug

首次构建尝试将花费半个多小时,因为 Buildozer 将通过 inte.net 将所需内容收集到 Python 项目的.buildozer文件夹中。 下一次构建尝试会更快。

暂无
暂无

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

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