我使用此代码,并在py charm上运行
import kivy
from kivy.app import App
from kivy.uix.label import Label
class MyApp(App):
def build(self):
return Label(text="gw hidup")
if __name__ == "__main__":
MyApp().run()
这是我运行后出来的
[INFO ] [Logger ] Record log in C:\Users\xeryd\.kivy\logs\kivy_20-08-04_7.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.angle" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.7.8 (tags/v3.7.8:4b47a5b6ba, Jun 28 2020, 08:53:46) [MSC v.1916 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_pil, img_gif (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 (e.g. 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: The specified module could not be found.
File "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\core\__init__.py", line 63, in core_select_lib
fromlist=[modulename], level=0)
File "C:\Users\xeryd\PycharmProjects\pythonProject1\venv\lib\site-packages\kivy\core\window\window_sdl2.py", line 27, in <module>
from kivy.core.window._window_sdl2 import _WindowSDL2Storage
[CRITICAL] [App ] Unable to get a Window, abort.
为什么会出现这种情况,我该怎么办?
答案 0 :(得分:1)
此解决方案可能会在OS OSX或Win上帮助您
#qpy:kivy
import kivy
kivy.require('1.10.1') # **REPLACE WITH CURRENT KIVY VERSION** To Get Rid Of This error--> [CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. 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
from kivy import Config
Config.set('graphics', 'multisamples', '0') # **To Get Rid Of The Open GL 2.0 Error**
答案 1 :(得分:1)
@zidanhadipratama
您的评论的答案,
# The Other Imports
import kivy
kivy.require('1.10.1')
from kivy.app import App
from kivy.uix.label import Label
# Make Sure This Is Always the last import
from kivy import Config
Config.set('graphics', 'multisamples', '0')
# Main Code
class MyApp(App):
def build(self):
return Label(text="Hello, World!")
# Run This Thing
if __name__ == "__main__":
MyApp().run()