简体   繁体   中英

Why do I get this python kivy error: CRITICAL] [App ] Unable to get a Window, abort?

I am trying to make a basic hello world program in kivy using python but I am still getting this error: [CRITICAL] [App ] Unable to get a Window, abort.

I have installed kivy using pip with these commands:

python -m pip install --upgrade pip wheel setuptools

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew -> (when installing this I also got that: WARNING: Ignoring invalid distribution -ip)

python -m pip install kivy.deps.gstreamer

python -m pip install kivy.deps.angle

python -m pip install kivy

This is the full error:

[INFO ] [Logger ] Record log in C:\\Users.kivy\\logs\\kivy_21-08-19_60.txt

[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.3.2

[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.3.0

[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.3.0

[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.3.1

[INFO ] [Kivy ] v2.0.0

[INFO ] [Kivy ] Installed at "C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\kivy_ init _.py"

[INFO ] [Python ] v3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)]

[INFO ] [Python ] Interpreter at "C:\\Users\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\python.exe"

[INFO ] [Factory ] 186 symbols loaded

[INFO ] [Image ] Providers: img_tex, img_dds, img_pil (img_sdl2, img_ffpyplayer ignored)

[INFO ] [Text ] Provider: pil(['text_sdl2'] ignored)

[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (eg add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes sdl2 - ImportError: DLL load failed while importing window_sdl2: The specified module could not be found. File "C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\kivy\\core_ init .py", line 58, in core_select_lib mod = import (name='{2}.{0}.{1}'.format( File "C:\\Users\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\site-packages\\kivy\\core\\window\\window_sdl2.py", line 27, in from kivy.core.window._window_sdl2 import _WindowSDL2Storage

[CRITICAL] [App ] Unable to get a Window, abort.

And this is my code:

import kivy
from kivy.app import App
from kivy.uix.label import Label

kivy.require('2.0.0')  

# Defining a class
class MyFirstKivyApp(App):
    
    def build(self):
        return Label(text ="Hello World !")          
  
MyFirstKivyApp().run()  

If you use conda then it must be a dependency probelm. Unistall kivy and then install it using conda (Not pip) if that didn't work then install kivy using a virtual environment. The latter method will work for sure but if you don't want that you work on a virtual environment than you can copy the folder kivy to your enviroment and replace it along with share folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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