在 Windows 10 上安装 Kivy 的问题

Posted

技术标签:

【中文标题】在 Windows 10 上安装 Kivy 的问题【英文标题】:Problems installing Kivy on Windows 10 【发布时间】:2020-05-16 05:24:26 【问题描述】:

我正在按照文档 https://kivy.org/doc/stable/installation/installation-windows.html 上的说明进行操作

已经到了舞台

Install kivy:

python -m pip install kivy==1.11.1

在此之前的一切都运行良好。我已经使用 --verison 检查了我的 python 版本和 pip 版本。我有 Python 3.8.1 和 pip 20.0.2 (python 3.8)。

首先这一步没有用,我得到了ERROR: Failed building wheel for kivy

于是我环顾四周,发现可以直接下载一个***。于是我下载了https://kivy.org/downloads/appveyor/kivy/Kivy-2.0.0rc1.20200130.318720360-cp38-cp38-win_amd64.whl 我认为这将是正确的版本,因为我有 python 3.8 和 64 位处理器。

但是,当我尝试 python -m pip install Kivy-2.0.0rc1.20200130.318720360-cp38-cp38-win_amd64.whl 时,我收到以下错误:

ERROR: Could not find a version that satisfies the requirement Kivy-2.0.0rc1-cp38-cp38-win_amd64 (from versions: none)
ERROR: No matching distribution found for Kivy-2.0.0rc1-cp38-cp38-win_amd64

EDIT ERROR: Failed building wheel for kivy 后面的完整错误:

    C:\Users\User>python -m pip install kivy==1.11.1
Collecting kivy==1.11.1
  Using cached Kivy-1.11.1.tar.gz (23.6 MB)
Processing c:\users\user\appdata\local\pip\cache\wheels\d2\72\1a\9ddd17f00755707937caa350616965fb3330a6270425f397e6\kivy_garden-0.1.4-py3-none-any.whl
Collecting docutils
  Using cached docutils-0.16-py2.py3-none-any.whl (548 kB)
Collecting pygments
  Using cached Pygments-2.5.2-py2.py3-none-any.whl (896 kB)
Collecting requests
  Using cached requests-2.22.0-py2.py3-none-any.whl (57 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.8-py2.py3-none-any.whl (125 kB)
Collecting idna<2.9,>=2.5
  Using cached idna-2.8-py2.py3-none-any.whl (58 kB)
Collecting chardet<3.1.0,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2019.11.28-py2.py3-none-any.whl (156 kB)
Building wheels for collected packages: kivy
  Building wheel for kivy (setup.py) ... error
  ERROR: Command errored out with exit status 3221225477:
   command: 'C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\User\AppData\Local\Temp\pip-wheel-q23wvn82'
       cwd: C:\Users\User\AppData\Local\Temp\pip-install-i_dh93mc\kivy\
  Complete output (531 lines):
  Using setuptools
  User distribution detected, avoid portable command.
  Using this graphics system: OpenGL
  WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)

  b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

  WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)

  b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

  WARNING: A problem occurred while running pkg-config --libs --cflags sdl2 SDL2_ttf SDL2_image SDL2_mixer (code 1)

  b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

  ERROR: Dependency for context.pyx not resolved: config.pxi
  ERROR: Dependency for compiler.pyx not resolved: config.pxi
  ERROR: Dependency for context_instructions.pyx not resolved: config.pxi
  ERROR: Dependency for fbo.pyx not resolved: config.pxi
  ERROR: Dependency for gl_instructions.pyx not resolved: config.pxi
  ERROR: Dependency for instructions.pyx not resolved: config.pxi
  ERROR: Dependency for opengl.pyx not resolved: config.pxi
  ERROR: Dependency for opengl_utils.pyx not resolved: config.pxi
  ERROR: Dependency for shader.pyx not resolved: config.pxi
  ERROR: Dependency for stencil_instructions.pyx not resolved: config.pxi
  ERROR: Dependency for scissor_instructions.pyx not resolved: config.pxi
  ERROR: Dependency for texture.pyx not resolved: config.pxi
  ERROR: Dependency for vbo.pyx not resolved: config.pxi
  ERROR: Dependency for vertex.pyx not resolved: config.pxi
  ERROR: Dependency for vertex_instructions.pyx not resolved: config.pxi
  ERROR: Dependency for cgl.pyx not resolved: config.pxi
  ERROR: Dependency for cgl_mock.pyx not resolved: config.pxi
  ERROR: Dependency for cgl_gl.pyx not resolved: config.pxi
  ERROR: Dependency for cgl_glew.pyx not resolved: config.pxi
  ERROR: Dependency for cgl_sdl2.pyx not resolved: config.pxi
  ERROR: Dependency for svg.pyx not resolved: config.pxi
  fatal: not a git repository (or any of the parent directories): .git
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.8
  creating build\lib.win32-3.8\kivy
  copying kivy\animation.py -> build\lib.win32-3.8\kivy
  copying kivy\app.py -> build\lib.win32-3.8\kivy
  copying kivy\atlas.py -> build\lib.win32-3.8\kivy
  copying kivy\base.py -> build\lib.win32-3.8\kivy
  **lots more of this, cut for char limit**

  ----------------------------------------
  ERROR: Failed building wheel for kivy
  Running setup.py clean for kivy
Failed to build kivy
Installing collected packages: urllib3, idna, chardet, certifi, requests, Kivy-Garden, docutils, pygments, kivy
    Running setup.py install for kivy ... error
    ERROR: Command errored out with exit status 3221225477:
     command: 'C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-817ny_l6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\User\AppData\Local\Programs\Python\Python38-32\Include\kivy'
         cwd: C:\Users\User\AppData\Local\Temp\pip-install-i_dh93mc\kivy\
    Complete output (513 lines):
    Using setuptools
    User distribution detected, avoid portable command.
    Using this graphics system: OpenGL
    WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)

    b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

    WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)

    b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

    WARNING: A problem occurred while running pkg-config --libs --cflags sdl2 SDL2_ttf SDL2_image SDL2_mixer (code 1)

    b"'pkg-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"

    fatal: not a git repository (or any of the parent directories): .git
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.8
    creating build\lib.win32-3.8\kivy
    copying kivy\animation.py -> build\lib.win32-3.8\kivy
    copying kivy\app.py -> build\lib.win32-3.8\kivy
    copying kivy\atlas.py -> build\lib.win32-3.8\kivy
    ** again cut due to char limit **

    copying kivy\tools\theming\defaulttheme\tab_btn_pressed.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\tab_disabled.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\textinput.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\textinput_active.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\textinput_disabled.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\textinput_disabled_active.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\tree_closed.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\tree_opened.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_background.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_disabled_background.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_disabled_key_down.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_disabled_key_normal.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_key_down.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    copying kivy\tools\theming\defaulttheme\vkeyboard_key_normal.png -> build\lib.win32-3.8\kivy\tools\theming\defaulttheme
    running build_ext
    ----------------------------------------
ERROR: Command errored out with exit status 3221225477: 'C:\Users\User\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"'; __file__='"'"'C:\\Users\\User\\AppData\\Local\\Temp\\pip-install-i_dh93mc\\kivy\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\User\AppData\Local\Temp\pip-record-817ny_l6\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\User\AppData\Local\Programs\Python\Python38-32\Include\kivy' Check the logs for full command output.

【问题讨论】:

你可以编辑以包含ERROR: Failed building wheel for kivy后面的完整错误 当然我会在几秒钟内编辑...这是一个很大的 谢谢,这将有助于找出构建源代码失败的原因。至于为什么安装whl文件失败,看我的回答 【参考方案1】:

尝试使用它。在同样的情况下为我工作。

pip install kivy[base] kivy_examples --pre --extra-index-url https://kivy.org/downloads/simple/

在 32 位和 64 位的 python 3.8.2 上工作,操作系统:win10

【讨论】:

谢谢!这很有效,但你能解释一下为什么有效吗? @simon 为 python 3.7 或更早版本制作的 kivy 正常版本(可通过 pip 下载)。所以他们不在 3.8 上运行。然而,他们为 3.8 制作了一个并将其保存在他们的 git repo 中(可能正在开发中),因此我们(python 3.8 用户)需要从那里安装它。 也在最新的 3.8.6 上工作,但在 py 3.9.0rc2 上还没有工作(测试)【参考方案2】:

python -m pip install kivy==1.11.1 只能从 pypi 下载源代码分发,因为 pypi 上没有可用于 python 3.8 的 whl 文件。构建源包似乎失败了,这可能有几个原因

另外,你已经安装了32位python(可能是无意的),从安装位置Python38-32可以看到。这就是为什么您的whl 文件无法安装的原因,因为它适用于 win64。我建议卸载你的 python 并重新安装 64 位版本

【讨论】:

更新...用 .whl 试了一下,得到了这个ERROR: Kivy-2.0.0rc1.20200130.318720360-cp38-cp38-win_amd64.whl is not a supported wheel on this platform. 可以在终端执行python -c "import wheel.pep425tags as w; print(w.get_supported())"吗? C:\Users\User&gt;python -c "import wheel.pep425tags as w; print(w.get_supported())" Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; TypeError: get_supported() missing 1 required positional argument: 'archive_root'【参考方案3】:

我使用下面的链接在我的 Windows 10 中安装了 kivy。 我正在使用python 3.9。 希望它也对你有用。

https://kivy.org/doc/stable-1.10.1/installation/installation-windows.html

【讨论】:

【参考方案4】:

我使用了 中提到的命令并为我工作我正在使用 python 3.10.2

【讨论】:

您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。

以上是关于在 Windows 10 上安装 Kivy 的问题的主要内容,如果未能解决你的问题,请参考以下文章

无法安装 Kivy(Windows 10,python 3.8)[重复]

在 Windows 10 上安装 Kivy 时,错误消息“致命错误 C1083:无法打开包含文件:'GL/glew.h':没有这样的文件或目录”

我尝试在 Windows 10 上为 python 3.8.1 安装 kivy,但出现此错误 [重复]

Windows上安装-kivy

如何在 android 设备上运行我的 kivy windows 应用程序

安装 KIVY 时出错:为啥执行后出现错误:“python -m pip install kivy”?