Raspberry Pi Python(Kivy)的sudo速度非常慢 [英] Raspberry Pi Python (Kivy) extremely slow with sudo

查看:155
本文介绍了Raspberry Pi Python(Kivy)的sudo速度非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在用KivyPie OS(为Kivy开发预先配置的Linux)在Raspberry Pi上编写Kivy图形程序.

I've been writing a Kivy graphical program on Raspberry Pi, with the KivyPie OS (Linux pre-configured for Kivy development).

由于某种原因,如果以sudo开头,它的运行速度非常慢. 通常,运行"python main.py"时,程序以每秒约30个周期的速度运行. 但是,如果我执行"sudo python main.py",则它每5-10秒运行1个周期.

For some reason, it's running extremely slow if started with sudo. Normally, running "python main.py", the program runs at about 30 cycles per second. However, if I do "sudo python main.py", it runs as slowly as 1 cycle per 5-10 seconds.

我需要使用sudo来访问Raspberry的GPIO. (除非我尝试其他方法,否则我会看到人们在讨论).

I need to use sudo to access Raspberry's GPIO. (unless I try some other way to do it, that I see people discuss).

我很感兴趣,但是sudo如此巨大的性能下降可能是什么原因?可以解决这个问题吗?

I'm interested, though, what could be the cause of such a massive performance drop with sudo? And is it possible to work around that?

PS:无论是否在sudo上,在我的PC(Linux)上运行相同的程序似乎都不会引起此类问题.仅在树莓上.

PS: Running the same program on my PC (Linux) with and without sudo doesn't seem to cause such problem. Only on Raspberry.

推荐答案

好吧,即使有几个问题,我也称这个问题已解决.

Well, I would call this problem solved, even if a few questions remain.

以下是关键点:

  • 变慢的原因是Kivy无法在"sudo"下加载正确的视频驱动程序,而是使用软件渲染.
  • 我还没有弄清楚为什么驱动程序没有加载sudo或如何修复它.但是...
  • 使用Pyinstaller编译程序后,一切正常.可执行文件可以使用sudo启动,GPIO可以正常工作,Kivy可以加载适当的驱动程序,一切都可以正常运行.

总而言之,已经找到了最初问题的原因,但尚未找到直接使用Python启动程序的修复程序,但是已通过使用Pyinstaller编译程序来解决了该问题. (仍然不是调试的便捷方法.)

To sum it up, the reason of the initial problem has been found, no fix for launching the program directly with Python was yet found, but the problem was removed by compiling the program with Pyinstaller. (still, not a convenient way for debugging.)

这篇关于Raspberry Pi Python(Kivy)的sudo速度非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆