简体   繁体   English

"Kivy 2.0.0,python 3.9 错误:[CRITICAL] [Window] 无法找到任何有价值的 Window 提供程序"

[英]Kivy 2.0.0 , python 3.9 error: [CRITICAL] [Window ] Unable to find any valuable Window provider

I've been having this same error running any kivy code I type into IntelliJ.运行我在 IntelliJ 中键入的任何 kivy 代码时,我一直遇到同样的错误。 I'm using kivy 2.0.0 and Python 3.9.我正在使用 kivy 2.0.0 和 Python 3.9。 Here's my code:这是我的代码:

import kivy
kivy.require("2.0.0")
from kivy.app import App
from kivy.uix.button import Button

print(kivy.__version__)

class ButtonApp(App):
    def build(self):
        # use a (r, g, b, a) tuple
        btn = Button(text="Push Me !",
                     font_size="20sp",
                     background_color=(1, 1, 1, 1),
                     color=(1, 1, 1, 1),
                     size=(32, 32),
                     size_hint=(.2, .2),
                     pos=(300, 250))

        btn.bind(on_press=self.callback)
        return btn

    def callback(self, event):
        print("button pressed")
        print('Yoooo !!!!!!!!!!!')

root = ButtonApp()

root.run()

I've tried many solutions including: reinstalling kivy, adding to path, and I've installed all the dependencies.我尝试了许多解决方案,包括:重新安装 kivy,添加到路径,并且我已经安装了所有依赖项。 Here's the error message:这是错误消息:

[INFO   ] [Logger      ] Record log in C:\Users\James\.kivy\logs\kivy_21-10-25_21.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\james\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "C:\Users\james\IdeaProjects\HelloWorld\venv\Scripts\python.exe"
[INFO   ] [Logger      ] Purge log fired. Analysing...
[INFO   ] [Logger      ] Purge 9 log files
[INFO   ] [Logger      ] Purge finished!
[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)
2.0.0
[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 while importing _window_sdl2: The specified module could not be found.
  File "C:\Users\james\AppData\Local\Programs\Python\Python39\lib\site-packages\kivy\core\__init__.py", line 58, in core_select_lib
    mod = __import__(name='{2}.{0}.{1}'.format(
  File "C:\Users\james\AppData\Local\Programs\Python\Python39\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.

Process finished with exit code 1

EDIT So thanks to weebify I got through, I posted the full method I used as an answer.编辑所以感谢weebify我通过了,我发布了我用作答案的完整方法。

The solution for this problem is to uninstall kivy and reinstall the cutting-edge version from master:这个问题的解决方法是卸载kivy ,从master重新安装尖端版本:

python3 -m pip uninstall kivy
python3 -m pip install "kivy[base] @ https://github.com/kivy/kivy/archive/master.zip"

Ok, so many thanks to Weebify for help here.好的,非常感谢 Weebify 在这里提供的帮助。 Here are the full download instructions for Windows for anyone who is having problems:以下是 Windows 的完整下载说明,适用于遇到问题的任何人:

?

NOTE: Kivy does not yet support Python 3.10 but you can get through fine with Python 3.9<\/strong>注意:Kivy 尚不支持 Python 3.10,但您可以使用 Python 3.9 顺利完成<\/strong><\/h2>

?

Setup terminal and pip<\/strong>设置终端和点子<\/strong><\/h2>

Before Kivy can be installed, Python and pip need to be pre-installed<\/strong> .在安装 Kivy 之前,需要预先安装 Python 和 pip<\/strong> 。 Then, start a new terminal that has Python available.然后,启动一个可以使用 Python 的新终端。 In the terminal, update pip and other installation dependencies so you have the latest version as follows, (for linux users you may have to substitute python3 instead of python and also add a --user flag in the subsequent commands outside the virtual environment):<\/em>在终端中,更新 pip 和其他安装依赖项,以便您拥有最新版本,如下所示(对于 linux 用户,您可能必须替换 python3 而不是 python,并在虚拟环境之外的后续命令中添加 --user 标志):<\/em>

 python -m pip install --upgrade pip setuptools virtualenv<\/code><\/pre> 
                 

Create virtual environment<\/strong>创建虚拟环境<\/strong><\/h2>
  1. Create a new virtual environment for your Kivy project.为您的 Kivy 项目创建一个新的虚拟环境。 A virtual environment will prevent possible installation conflicts with other Python versions and packages.虚拟环境将防止与其他 Python 版本和包可能发生的安装冲突。 It's optional but strongly recommended:它是可选的,但强烈推荐:<\/li><\/ol>

    Create the virtual environment named kivy_venv in your current directory:在当前目录中创建名为 kivy_venv 的虚拟环境:

     python -m virtualenv kivy_venv<\/code><\/pre> 
                            
                            
    1. Activate the virtual environment.激活虚拟环境。 You will have to do this step from the current directory every time you start a new terminal.每次启动新终端时,您都必须从当前目录执行此步骤。 This sets up the environment so the new kivy_venv Python is used.这设置了环境,因此使用了新的 kivy_venv Python。<\/li><\/ol>

      For Windows default CMD, in the command line do:对于 Windows 默认 CMD,在命令行中执行:

       kivy_venv\\Scripts\\activate<\/code><\/pre>

      If you are in a bash terminal on Windows, instead do:如果您在 Windows 上的 bash 终端中,请执行以下操作:

       source kivy_venv\/Scripts\/activate<\/code><\/pre>

      If you are in Linux, instead do:如果您在 Linux 中,请改为:

       source kivy_venv\/bin\/activate<\/code><\/pre>

      Your terminal should now preface the path with something like (kivy_venv), indicating that the kivy_venv environment is active.您的终端现在应该在路径前加上 (kivy_venv) 之类的东西,表示 kivy_venv 环境处于活动状态。 If it doesn't say that, the virtual environment is not active and the following won't work.如果没有这样说,则虚拟环境未激活,以下将不起作用。


      Install Kivy<\/strong>安装 Kivy<\/strong><\/h2>

      Finally, install Kivy using the latest cutting-edge Kivy from master:<\/strong>最后,使用 master 提供的最新尖端 Kivy 安装 Kivy:<\/strong>

       python -m pip install "kivy[base] @ https:\/\/github.com\/kivy\/kivy\/archive\/master.zip"<\/code><\/pre>

      More info on the Kivy installation page.<\/a>有关Kivy 安装页面的更多信息。<\/a>

      "

Ok, so thanks to Weebify.好的,感谢 Weebify。 Here are the full download instructions for anyone who is having problems, follow the instructions for your OS and get the master version: https://kivy.org/doc/stable/gettingstarted/installation.html以下是为遇到问题的任何人提供的完整下载说明,请按照适用于您的操作系统的说明获取主版本: https : //kivy.org/doc/stable/gettingstarted/installation.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kivy 不工作(错误:无法找到任何有价值的 Window 提供程序。) - Kivy not working (Error: Unable to find any valuable Window provider.) Kivy 错误 - 无法找到任何有价值的 Window 提供程序 - Kivy error - Unable to find any valuable Window provider Kivy 不工作。 [CRITICAL] [Window] 找不到任何有价值的 Window 提供程序 - Kivy isn't working. [CRITICAL] [Window ] Unable to find any valuable Window provider “无法找到任何有价值的Window提供程序”错误 - “Unable to find any valuable Window provider” Error Python Kivy严重文本错误。 找不到任何有价值的文本提供者 - Python Kivy Critical Text Error. Unable to Find any valuable Text provider Python, kivy 错误 [CRITICAL][Video] 无法找到任何有价值的视频提供者 - Python, kivy error [CRITICAL][Video] unable to find any valuable video provider Kivy错误,[CRITICAL] [Text]无法找到任何有价值的文本提供程序(python 3.6.1)(Windows 10) - Kivy error, [CRITICAL] [Text ] unable to find any valuable text provider (python 3.6.1) (windows 10) Kivy - windows - 根本找不到任何有价值的 Window 提供程序 - Kivy - windows - Unable to find any valuable Window provider at all Python 3.7.7 Kivy:找不到任何有价值的 Window 提供程序。 sdl2 - ValueError: 不是 boolean: 400 - Python 3.7.7 Kivy: Unable to find any valuable Window provider. sdl2 - ValueError: Not a boolean: 400 Kivy应用程序未正确统计? 找不到任何有价值的Window提供程序 - Kivy Application did not stat correctly? Unable to find any valuable Window provider
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM