You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无法通过pip安装sh模块与buildozer模块的问题排查及解决请求

解决Windows下pip安装buildozer失败的问题

问题概述

在Windows系统中执行pip install buildozer命令时安装失败,核心原因是buildozer依赖的sh模块在导入fcntl模块时出错——Windows系统原生不支持fcntl模块,最终导致元数据生成失败。

错误日志

C:\Users\Administrator>pip install buildozer
 Collecting buildozer
Using cached buildozer-1.4.0-py3-none-any.whl (84 kB)
Collecting pexpect
Using cached pexpect-4.8.0-py2.py3-none-any.whl (59 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 "", line 2, in
File "", line 34, in
File "C:\Users\Administrator\AppData\Local\Temp\pip-install-hg1fn8lo\sh_45a7ec2824b04794ac4fe58ef669a78f\setup.py", line 5, in
import sh
File "C:\Users\Administrator\AppData\Local\Temp\pip-install-hg1fn8lo\sh_45a7ec2824b04794ac4fe58ef669a78f\sh.py", line 37, in
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.
See above for details.

当前已安装包列表

包名版本
certifi2022.9.24
charset-normalizer2.1.1
docutils0.19
ez-setup0.9
idna3.4
Kivy2.1.0
kivy-deps.angle0.3.2
kivy-deps.glew0.3.1
kivy-deps.sdl20.4.5
Kivy-Garden0.1.5
pip22.3
Pygments2.13.0
pypiwin32223
pywin32304
requests2.28.1
setuptools65.5.0
supertools1.0.1
urllib31.26.12

解决方案

方案一:使用WSL(推荐)

buildozer的开发和运行环境以Linux为主,很多依赖仅支持类Unix系统,WSL可以在Windows上模拟Linux环境,从根源解决兼容性问题:

  • 启用Windows的WSL功能,并安装Ubuntu等Linux发行版
  • 在WSL终端内执行以下命令:
    sudo apt update && sudo apt upgrade -y
    sudo apt install python3 python3-pip -y
    pip3 install buildozer
    

方案二:尝试Windows兼容的sh模块(临时方案)

此方法仅能解决安装阶段的问题,后续buildozer运行可能仍出现其他兼容性错误:

  • 先安装Windows兼容的sh替代包:
    pip install sh-win
    
  • 再执行buildozer安装命令:
    pip install buildozer
    

内容的提问来源于stack exchange,提问作者J Raghavendra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 15:45:42