我试图启动kivy应用程序,但窗口没有打开,我应该怎么做才能使代码正常工作?

时间:2019-08-29 08:21:37

标签: python macos terminal kivy

我正在启动Kivy文件,但是窗口没有打开

试图升级奇异果:

pip3 install kivy
pip3 install --upgrade kivy
from kivy.app import App

class MyApp(App):
    pass

if __name__ == "__main__":
    MyApp().run

我希望输出将是一个新的空白kivy窗口。但是输出是

[192:~/Desktop/Kivy/hello_world_kivy] makar% /Library/Frameworks/Python.framework/Versions/3.7/bin/python3 /Users/makar/Desktop/Kivy/hello_world_kivy/kivyhello.py
[INFO   ] [Logger      ] Record log in /Users/makar/.kivy/logs/kivy_19-08-29_22.txt
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.7.4 (v3.7.4:e09359112e, Jul  8 2019, 14:54:52) 
[Clang 6.0 (clang-600.0.57)]
[INFO   ] [Python      ] Interpreter at "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"
[INFO   ] [Factory     ] 184 symbols loaded
objc[4569]: Class SDLApplication is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f378) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b291b0). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLAppDelegate is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f3c8) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29200). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLTranslatorResponder is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f440) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29278). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLMessageBoxPresenter is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f648) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b292a0). One of the two will be used. Which one is undefined.
objc[4569]: Class SDL_cocoametalview is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f328) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b292f0). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLOpenGLContext is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f468) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29340). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLWindow is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f4b8) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29390). One of the two will be used. Which one is undefined.
objc[4569]: Class Cocoa_WindowListener is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f4e0) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b293b8). One of the two will be used. Which one is undefined.
objc[4569]: Class SDLView is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f558) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29430). One of the two will be used. Which one is undefined.
objc[4569]: Class METAL_RenderData is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f5a8) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b29480). One of the two will be used. Which one is undefined.
objc[4569]: Class METAL_TextureData is implemented in both /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/kivy/.dylibs/SDL2 (0x10360f5f8) and /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ffpyplayer/.dylibs/libSDL2-2.0.0.dylib (0x105b294d0). One of the two will be used. Which one is undefined.
[INFO   ] [ImageLoaderFFPy] Using ffpyplayer 4.2.0
[INFO   ] [Image       ] Providers: img_tex, img_imageio, img_dds, img_sdl2, img_pil, img_ffpyplayer, img_gif 
[192:~/Desktop/Kivy/hello_world_kivy] makar%

1 个答案:

答案 0 :(得分:1)

您只是忘记了括号来调用函数run。

像这样尝试:

from kivy.app import App

class MyApp(App):
    pass

if __name__ == "__main__":
    MyApp().run()