问题
I'm in a AMD 64 bits Windows 10 computer in french with python 3.8.5
First I try to install kivy with the help of the official website (https://kivy.org/doc/stable/installation/installation-windows.html)
but it failed while «Building wheel for kivy (setup.py)»
The complet error has a length of 531 lines so I show only the more important part
ERROR: Command errored out with exit status 3221225477:
command: 'c:\users\%myusername%\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\%myusername%\\AppData\\Local\\Temp\\pip-install-payt_kgr\\kivy\\setup.py'"'"'; __file__='"'"'C:\\Users\\%myusername%\\AppData\\Local\\Temp\\pip-install-payt_kgr\\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\%myusername%\AppData\Local\Temp\pip-wheel-a9go4zcz'
cwd: C:\Users\%myusername%\AppData\Local\Temp\pip-install-payt_kgr\kivy\
WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)
b"'pkg-config' n'est pas reconnu en tant que commande interne\r\nou externe, un programme ex\x82cutable ou un fichier de commandes.\r\n"
WARNING: A problem occurred while running pkg-config --libs --cflags gstreamer-1.0 (code 1)
b"'pkg-config' n'est pas reconnu en tant que commande interne\r\nou externe, un programme ex\x82cutable ou un fichier de commandes.\r\n"
WARNING: A problem occurred while running pkg-config --libs --cflags sdl2 SDL2_ttf SDL2_image SDL2_mixer (code 1)
b"'pkg-config' n'est pas reconnu en tant que commande interne\r\nou externe, un programme ex\x82cutable ou un fichier de commandes.\r\n"
ERROR: Dependency for context.pyx not resolved: config.pxi
(...)
fatal: not a git repository (or any of the parent directories): .git
ERROR: Command errored out with exit status 3221225477: 'c:\users\%myusername%\appdata\local\programs\python\python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\%myusername%\\AppData\\Local\\Temp\\pip-install-payt_kgr\\kivy\\setup.py'"'"'; __file__='"'"'C:\\Users\\%myusername%\\AppData\\Local\\Temp\\pip-install-payt_kgr\\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\%myusername%\AppData\Local\Temp\pip-record-8x9xz8go\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\%myusername%\appdata\local\programs\python\python38\Include\kivy' Check the logs for full command output.
After I tried to install kivy with the github source at (https://github.com/kivy/kivy) and run «python setup.py install»
It's failed
kivy\include\gl_redirect.h(37): fatal error C1083: Impossible d'ouvrir le fichier include : 'GL/glew.h' : No such file or directory
error: command 'D:\\programme\\visual code\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2
So I moved the directory kivy (in the source of github) to my lib directory («C:\Users\%myusername%\AppData\Local\Programs\Python\Python38\Lib») and I could import kivy that show those logs in the import
[INFO ] [Logger ] Record log in C:\Users\%myusername%\.kivy\logs\kivy_20-07-24_19.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.1.18
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.1.10
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.1.12
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.1.23
[INFO ] [Kivy ] v2.0.0rc3, git-Unknown, 20200724
[INFO ] [Kivy ] Installed at "C:\Users\%myusername%\AppData\Local\Programs\Python\Python38\lib\kivy\__init__.py"
[INFO ] [Python ] v3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\%myusername%\AppData\Local\Programs\Python\Python38\python.exe"
But when a run a simple hello world file it doesn't work and show the logs with an error:
[INFO ] [Logger ] Record log in C:\Users\rapha\.kivy\logs\kivy_20-07-24_20.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.1.18
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.1.10
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.1.12
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.1.23
[INFO ] [Kivy ] v2.0.0rc3, git-Unknown, 20200724
[INFO ] [Kivy ] Installed at "C:\Users\rapha\AppData\Local\Programs\Python\Python38\lib\kivy\__init__.py"
[INFO ] [Python ] v3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:57:54) [MSC v.1924 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\rapha\AppData\Local\Programs\Python\Python38\python.exe"
[ERROR ] [Clock ] Unable to import kivy._clock. Have you perhaps forgotten to compile kivy? Kivy contains Cython code which needs to be compiled. A missing kivy._clock often indicates the Cython code has not been compiled. Please follow the installation instructions and make sure to compile Kivy
Traceback (most recent call last):
File "test.py", line 1, in <module>
from kivy.app import App
File "C:\Users\rapha\AppData\Local\Programs\Python\Python38\lib\kivy\app.py", line 411, in <module>
from kivy.base import runTouchApp, async_runTouchApp, stopTouchApp
File "C:\Users\rapha\AppData\Local\Programs\Python\Python38\lib\kivy\base.py", line 28, in <module>
from kivy.clock import Clock
File "C:\Users\rapha\AppData\Local\Programs\Python\Python38\lib\kivy\clock.py", line 466, in <module>
from kivy._clock import CyClockBase, ClockEvent, FreeClockEvent, \
ModuleNotFoundError: No module named 'kivy._clock'
I've watched the file "_clock", before loading setup.py it's a .pyx file and after it's a .c file.
回答1:
Use Python 3.7 or Kivy's latest alpha release.
Your specific issue is that you're trying to get a version of kivy that doesn't have wheels available for Python 3.8, so python tries to build kivy itself but you don't have most of the dependencies and the build doesn't work right. Also I think it wouldn't work even if you set up the build toolchain, as there's a small bugfix needed for Python 3.8 (hence the latest alpha, which has this bugfix, working).
来源:https://stackoverflow.com/questions/63085565/failed-to-install-the-module-kivy-in-windows-with-pip