I've been writing a Kivy graphical program on Raspberry Pi, with the KivyPie OS (Linux pre-configured for Kivy development).
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.
I need to use sudo to access Raspberry's GPIO. (unless I try some other way to do it, that I see people discuss).
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: Running the same program on my PC (Linux) with and without sudo doesn't seem to cause such problem. Only on Raspberry.
The problem is that Kivy is using an alternative config.ini file for the root user and not the one you have in ~/.kivy/config.ini
.
At the top of your python file you can add the following to force it to use the
egl_rpi
window:
import os
os.environ['KIVY_WINDOW'] = 'egl_rpi'
Alternatively, you can copy your ini file over to the root using:
sudo cp ~/.kivy/config.ini /root/.kivy/config.ini
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With