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

使用pip安装Kivy时出错,求问题原因及解决办法

Troubleshooting Kivy Installation Failures on Windows

Hey there, let's work through your Kivy installation issues using the error logs you shared. Here are the key problems and step-by-step fixes:

Key Issues Identified

  1. Missing wheel package: This caused the Cython build to fail with error: invalid command 'bdist_wheel'
  2. Network timeout: Your connection to PyPI timed out while fetching dependencies like Cython
  3. Missing pkg-config tool: Windows doesn't include this by default, but Kivy needs it to resolve system dependencies
  4. Cython version misalignment: Kivy requires a specific range of Cython versions that wasn't properly installed due to the above issues

Step-by-Step Fixes

1. Install/Upgrade Core Packaging Tools

First, ensure all essential packaging tools are up to date (even if you tried this before, a fresh run ensures no residual issues):

python -m pip install --upgrade pip setuptools wheel

2. Manually Install the Required Cython Version

Kivy specifies a strict Cython version range. Install it directly to avoid build conflicts:

python -m pip install "cython>=0.24,<=0.29.10,!=0.27,!=0.27.2"

3. Set Up pkg-config for Windows

Windows doesn't ship with pkg-config, which Kivy uses to locate system libraries like SDL and GStreamer:

  • Download the GTK+ Runtime Environment Installer (it includes pkg-config) matching your system architecture (32/64-bit)
  • After installation, find the bin folder in the installation directory (e.g., C:\Program Files\GTK3-Runtime Win64\bin)
  • Add this folder path to your System Environment Variables > PATH
  • Restart your command prompt, then verify it works by running:
    pkg-config --version
    

4. Install Kivy with a Stable Mirror and Extended Timeout

Use a reliable PyPI mirror to avoid network timeouts, and extend the timeout limit to prevent interruptions:

python -m pip install kivy --default-timeout=100 -i https://pypi.tuna.tsinghua.edu.cn/simple

Alternative: Use Precompiled Kivy Wheels

If compiling from source still fails, you can use pre-built Kivy wheel files (no compilation needed). Download the wheel file matching your Python version and Windows architecture, then install it with:

python -m pip install path/to/kivy-wheel-file.whl

内容的提问来源于stack exchange,提问作者12ksins

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.09 21:47:28