# Developing rpi-rgb-led based python code with thonny

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181>\
**Category:** Uncategorized\
**Created:** [March 29, 2021, 4:21pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181 "2021-03-29T16:21:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tadam](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tadam](https://rpi-rgb-led-matrix.discourse.group/u/tadam)\
**Post date:** [March 29, 2021, 4:21pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181/1 "2021-03-29T16:21:26Z")

</div>

Hello there,

I would like wrote some code to use my rgb led matrix.  
My issue is when I run my code I got this error in thony, and white line appear on the led panel:  
“Press CTRL-C to stop sample  
Can’t set realtime thread priority=99: Operation not permitted.  
You are probably not running as root ?  
This will seriously mess with color stability and flicker  
of the matrix. Please run as `root` (e.g. by invoking this  
program with `sudo`), or setting the capability on this  
binary by calling  
sudo setcap ‘cap\_sys\_nice=eip’ /usr/bin/python3.7”

My code is the following:  
#!/usr/bin/env python  
from samplebase import SampleBase  
from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics  
import time

```
class Show(SampleBase):
    def __init__ (self, *args, **kwargs):
        super(Show, self). __init__ (*args, **kwargs)
    
    def run(self):
        ops = RGBMatrixOptions()
        ops.rows = 20
        ops.cols = 40
        ops.chain_length = 2
        ops.parallel = 2
        ops.multiplexing = 10
        ops.row_address_type = 4
        ops.drop_privileges = False #This line should help but it doesn't :(

        matrix = RGBMatrix(options = ops)
        #matrix.Clear()
        
        graphics.DrawLine(matrix, 0, 40, 0, 39, graphics.Color(255,0,0))
        time.sleep(2)

# Main function
if __name__ == " __main__":
    show = Show()
    if (not show.process()):
        show.print_help()
```

---

<div class="post-metadata">

**Author:** ![marcmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/marcmerlin/32/40_2.png) [@marcmerlin](https://rpi-rgb-led-matrix.discourse.group/u/marcmerlin)\
**Post date:** [March 30, 2021, 3:36pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181/2 "2021-03-30T15:36:55Z")

</div>

And to be clear, you are already running python as root?

---

<div class="post-metadata">

**Author:** ![tadam](https://avatars.discourse-cdn.com/v4/letter/t/94ad74/32.png) [@tadam](https://rpi-rgb-led-matrix.discourse.group/u/tadam)\
**Post date:** [March 30, 2021, 8:21pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181/3 "2021-03-30T20:21:38Z")

</div>

I was runnin thonny as a root. The python command line was inside thonny in this case

---

<div class="post-metadata">

**Author:** ![muscleriot](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/muscleriot/32/75_2.png) [@muscleriot](https://rpi-rgb-led-matrix.discourse.group/u/muscleriot)\
**Post date:** [March 31, 2021, 12:42pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/developing-rpi-rgb-led-based-python-code-with-thonny/181/4 "2021-03-31T12:42:38Z")

</div>

Hi Yes I get thte same issue running SampleBase in python from samples directory under OSMC (debian)  
You cannot set thread resource priority on the pi - the limit is set to 0 .  
Cyril:~/rpi-rgb-led-matrix/bindings/python/samples$ ulimit  
0  
(There are no limits set up on the raspberry pi in /etc/security/limits.conf )

ls -l /usr/bin/python3.7  
-r-rwxr-xr-x 2 root root 3538304 Jul 25 2020 python3.7

Running the python process as root - maybe the sample.py has its own context?  
ls -  
l-rwxr-xr-x 1 osmc osmc 1146 Mar 27 11:49 runtext.py  
-rwxr-xr-x 1 osmc osmc 4991 Mar 27 11:49 samplebase.py  
-rwxr-xr-x 1 root root 5120 Mar 27 17:13 scroll.py

Will try chown samplebase.py…to root:root  
sudo chown root:root samplebase.py

→ run text  
Can’t set realtime thread priority=99: Operation not permitted.  
You are probably not running as root ?  
This will seriously mess with color stability and flicker  
of the matrix. Please run as `root` (e.g. by invoking this  
program with `sudo`), or setting the capability on this  
binary by calling  
sudo setcap ‘cap\_sys\_nice=eip’ /usr/bin/python3.7  
Press CTRL-C to stop sample

Nope! Will have to look over what its trying to do
