简体   繁体   中英

can't run kivy on windows

Why i cant run my kivy code in VS code? I installed it like this:

python -m pip install --upgrade pip wheel setuptools 

then:

python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew

python -m pip install kivy.deps.gstreamer

python –m pip install kivy

this is my code:

**from kivy.app import App

from kivy.uix.button import Button

class FirstKivy(App):
    
    def build(self):
        
        return Button(text="Welcome to LikeGeeks!")
    
FirstKivy().run()**

thats my error:

[INFO   ] [Logger      ] Record log in C:\Users\Asus\.kivy\logs\kivy_21-04-06_32.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\Asus\AppData\Roaming\Python\Python38\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)]
[INFO   ] [Python      ] Interpreter at "C:\Program Files (x86)\Python38-32\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 (e.g. add -d if running from the command line, or change the log level in the config) and r
e-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\Asus\AppData\Roaming\Python\Python38\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
    mod = __import__(name='{2}.{0}.{1}'.format(
  File "C:\Users\Asus\AppData\Roaming\Python\Python38\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.**

First create virtual environment to not mess up with other python installations:

python -m pip install --upgrade pip setuptools virtualenv
python -m virtualenv kivy_venv
kivy_venv\Scripts\activate

The simplest is to install the current stable version of kivy and optionally kivy_examples from the kivy-team provided PyPi wheels. Simply do:

python -m pip install kivy[base] kivy_examples

Checking the demo

Kivy should now be installed. You should be able to import kivy in Python or, if you installed the Kivy examples, run the demo (on Windows):

python kivy_venv\share\kivy-examples\demo\showcase\main.py

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