Python Kivy 无法获取窗口提供程序

问题描述 投票:0回答:1

我在 python kivy 中运行简单的 Hello world 程序时遇到错误。就在 5 分钟前它还在运行,然后这个错误开始出现。

[INFO   ] [Logger      ] Record log in /home/godfriend/.kivy/logs/kivy_24-04- 27_45.txt
[INFO   ] [Kivy        ] v2.3.0
[INFO   ] [Kivy        ] Installed at 
"/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/__init__.py"
[INFO   ] [Python      ] v3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0]
[INFO   ] [Python      ] Interpreter at "/home/godfriend/Documents/kivyEnv/bin/python"
[INFO   ] [Logger      ] Purge log fired. Processing...
[INFO   ] [Logger      ] Purge finished!
[INFO   ] [Factory     ] 195 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
[INFO   ] [Window      ] Provider: sdl2
[INFO   ] [Window      ] Provider: x11(['window_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 - ValueError: invalid literal for int() with base 10: '2683.464599609375'
 File "/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/core/__init__.py", line 71, in core_select_lib
cls = cls()
File "/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/core/window/window_sdl2.py", line 165, in __init__
super(WindowSDL, self).__init__()
File "/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/core/window/__init__.py", line 1062, in __init__
kwargs['width'] = Config.getint('graphics', 'width')
File "/usr/lib/python3.10/configparser.py", line 820, in getint
return self._get_conv(section, option, int, raw=raw, vars=vars,
File "/usr/lib/python3.10/configparser.py", line 810, in _get_conv
return self._get(section, conv, option, raw=raw, vars=vars,
File "/usr/lib/python3.10/configparser.py", line 805, in _get
return conv(self.get(section, option, **kwargs))

x11 - ValueError: invalid literal for int() with base 10: '2683.464599609375'
File "/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/core/__init__.py", line 71, in core_select_lib
cls = cls()
File "/home/godfriend/Documents/kivyEnv/lib/python3.10/site-packages/kivy/core/window/__init__.py", line 1062, in __init__
kwargs['width'] = Config.getint('graphics', 'width')
File "/usr/lib/python3.10/configparser.py", line 820, in getint
return self._get_conv(section, option, int, raw=raw, vars=vars,
File "/usr/lib/python3.10/configparser.py", line 810, in _get_conv
return self._get(section, conv, option, raw=raw, vars=vars,
File "/usr/lib/python3.10/configparser.py", line 805, in _get
return conv(self.get(section, option, **kwargs))

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

仅供参考,我正在使用 ubuntu 22.04 和 python3.10,是的,我也尝试将 python 更改为更小的版本,但仍然出现相同的错误。

我的代码

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


class MainApp(App):

    def build(self):
       return Label(text="Hello World")


obj = MainApp() 
obj.run()
python kivy
1个回答
0
投票

检查您的

config.ini
文件(通常位于主目录的
.kivy
文件夹中)或
main.ini
文件。如果它包含像
width = 2683.464599609375
这样的行,那么那就是你的问题。您可以删除该文件(将写入默认文件来替换它)。
width
属性必须是整数。

© www.soinside.com 2019 - 2024. All rights reserved.