gpt4 book ai didi

python - Kivy (Python) 程序在 Raspberry Pi 上崩溃 (crashlog)

转载 作者:太空宇宙 更新时间:2023-11-04 08:58:34 24 4
gpt4 key购买 nike

我最近按照 Kivy 网站上的说明在 Raspberry Pi(带有 Raspbian 系统)上安装了 Kivy。

我打算测试我编写的程序。它在我的 Linux Mint 计算机上运行良好。然而,在 Raspbian 上,它因链接到 Kivy 自己的函数之一的奇怪错误而崩溃。

这是终端输出:

$ python main.py
[INFO ] [Logger ] Record log in /home/pi/.kivy/logs/kivy_15-01-10_6.txt
[INFO ] Kivy v1.9.0-dev
[INFO ] [Python ] v2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3]
[INFO ] [Factory ] 173 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_gif, img_pygame (img_pil, img_ffpyplayer ignored)
[INFO ] [Window ] Provider: egl_rpi
[INFO ] [GL ] OpenGL version <OpenGL ES 2.0>
[INFO ] [GL ] OpenGL vendor <Broadcom>
[INFO ] [GL ] OpenGL renderer <VideoCore IV HW>
[INFO ] [GL ] OpenGL parsed version: 2, 0
[INFO ] [GL ] Shading version <OpenGL ES GLSL ES 1.00>
[INFO ] [GL ] Texture max size <2048>
[INFO ] [GL ] Texture max units <8>
[INFO ] [Shader ] fragment shader: <Compiled>
[INFO ] [Shader ] vertex shader: <Compiled>
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[INFO ] [GL ] NPOT texture support is available
[INFO ] [OSC ] using <multiprocessing> for socket
[INFO ] [ProbeSysfs ] device match: /dev/input/event0
[INFO ] [HIDInput ] Read event from </dev/input/event0>
[INFO ] [ProbeSysfs ] device match: /dev/input/event1
[INFO ] [HIDInput ] Read event from </dev/input/event1>
[INFO ] [ProbeSysfs ] device match: /dev/input/event2
[INFO ] [HIDInput ] Read event from </dev/input/event2>
[INFO ] [Base ] Start application main loop
[INFO ] [HIDMotionEvent] using <CHESEN USB Keyboard>
[INFO ] [HIDMotionEvent] using <CHESEN USB Keyboard>
[INFO ] [HIDMotionEvent] using <PixArt USB Optical Mouse>
[INFO ] [Base ] Leaving application in progress...
Traceback (most recent call last):
File "main.py", line 145, in <module>
MainApp().run()
File "/usr/local/lib/python2.7/dist-packages/kivy/app.py", line 825, in run
runTouchApp()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 484, in runTouchApp
EventLoop.window.mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 77, in mainloop
self._mainloop()
File "/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py", line 72, in _mainloop
EventLoop.idle()
File "/usr/local/lib/python2.7/dist-packages/kivy/base.py", line 324, in idle
Clock.tick()
File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 483, in tick
self._process_events()
File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 615, in _process_events
event.tick(self._last_tick, remove)
File "/usr/local/lib/python2.7/dist-packages/kivy/clock.py", line 374, in tick
ret = callback(self._dt)
TypeError: create_window() takes exactly 1 argument (2 given)

就像一个疯狂的猜测,为了看看它是如何工作的,我尝试编辑 Kivy 的“create_window()”函数,它位于“/usr/local/lib/python2.7/dist-packages/kivy/core/window/window_egl_rpi.py”,通过在其声明中添加可选参数。再次运行我的程序反而产生了某种段错误,所以我不再乱搞 Kivy 的代码...

知道如何修复此日志中提示的错误吗? (MainApp().run() 是我程序的最开始,其他一切都是 Kivy 函数,显然是由这个命令自动调用的)

最佳答案

我在相同的情况下遇到了相同的错误 - 我的程序在 Windows 机器上运行良好,但在 RPi 上崩溃并出现相同的错误。就我而言,我运行的是更新的 Python 版本 - 2.7.9。

Window.size 分配似乎是崩溃的根源:

class MainApp(App):
def build(self):
Window.size = (1280,800) # <---- Crashes on RPi

删除此分配修复了程序。

关于python - Kivy (Python) 程序在 Raspberry Pi 上崩溃 (crashlog),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27885528/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com