简体   繁体   English

无法安装buildozer

[英]Can't install buildozer

I was trying to install a tool called Buildozer that is used to compile python kivy programs into APKs.我试图安装一个名为Buildozer的工具,用于将 python kivy 程序编译成 APK。

I used我用了

pip3 install --user --upgrade buildozer

as the installation guide said but that error occurred:正如安装指南所说,但发生了错误:

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.

I tried to install another version of python but it didn't work.我尝试安装另一个版本的 python 但没有成功。

If someone can help me I will be grateful.如果有人可以帮助我,我将不胜感激。

Buildozer can't be used directly under Windows. It can be used on Windows running Ubuntu Linux via WSL. Windows下不能直接使用Buildozer,可以通过WSL在Windows运行Ubuntu Linux上使用。 The official installation instruction can be found here:官方安装说明可以在这里找到:

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

It recommends installing Java 17 but I personally had an issue with JDK 17 thus I recommend to install JDK 11 instead.它建议安装 Java 17,但我个人对 JDK 17 有疑问,因此我建议改为安装 JDK 11。

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

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

  2. Run installed Ubuntu (terminal window) from Windows Start Menu or using PyCharm Terminal:从 Windows 开始菜单或使用 PyCharm 终端运行已安装的 Ubuntu(终端窗口):

    在此处输入图像描述

  3. Install Buildozer on Ubuntu by running following commands:通过运行以下命令在 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. Now make sure your current Ubuntu directory is set to your Python project's directory.现在确保您当前的 Ubuntu 目录设置为您的 Python 项目目录。 If for example your project is stored within: C:\Kivy\Projects\MyHelloWorld , then change your Ubuntu current directory to /mnt/c/Kivy/Projects/MyHelloWorld :例如,如果您的项目存储在: C:\Kivy\Projects\MyHelloWorld ,则将您的 Ubuntu 当前目录更改为/mnt/c/Kivy/Projects/MyHelloWorld

     cd /mnt/c/Kivy/Projects/MyHelloWorld

    Note: using PyCharm terminal it will always set current directory to your project's folder注意:使用 PyCharm 终端,它将始终将当前目录设置为项目文件夹

  5. Make sure that your Windows user have Full Control access right to your project's folder under Windows确保您的 Windows 用户对 Windows 下的项目文件夹具有完全控制访问权限

  6. Generate initial buildozer.spec for your project under Ubuntu terminal:在 Ubuntu 终端下为您的项目生成初始buildozer.spec

     buildozer init
  7. Change buildozer.spec lines:更改 buildozer.spec 行:

     # android.accept_sdk_license = False

    to

     android.accept_sdk_license = True

    and

     #android.api = 27

    to

     android.api = 33
  8. You can build your project using for example:您可以使用例如以下内容构建您的项目:

     buildozer -v android debug

First build attempt will take more than half an hour, because Buildozer will collect required stuff over inte.net into .buildozer folder of your Python project.首次构建尝试将花费半个多小时,因为 Buildozer 将通过 inte.net 将所需内容收集到 Python 项目的.buildozer文件夹中。 Next build attempts will be more quicker.下一次构建尝试会更快。

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

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