# "Cant set realtime thread priority=99: Operation not permitted." Error when changing board options - Python

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-error-when-changing-board-options-python/306>\
**Category:** Uncategorized\
**Created:** [August 18, 2021, 6:03pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-error-when-changing-board-options-python/306 "2021-08-18T18:03:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jmc](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@Jmc](https://rpi-rgb-led-matrix.discourse.group/u/Jmc)\
**Post date:** [August 18, 2021, 6:03pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-error-when-changing-board-options-python/306/1 "2021-08-18T18:03:06Z")

</div>

Hi, I’ve been trying to work out the basics of using this library to write code for my LED matrix. I’ve got the demos working well with the addition of some runtime flags (–led-cols=64 etc.) however now that I’m trying to translate these into python code I am getting an error. The code is as follows:

> #!/usr/bin/env python  
> from samplebase import SampleBase  
> import time  
> from rgbmatrix import RGBMatrix, RGBMatrixOptions, graphics

> class LEDTest(SampleBase):  
> def **init** (self, \*args, \*\*kwargs):  
> super(LEDTest, self). **init** (\*args, \*\*kwargs)

```
def run(self):
    ops = RGBMatrixOptions()
    ops.hardware_mapping = 'adafruit-hat'
    ops.rows = 32
    ops.cols = 64
    ops.gpio_slowdown = 2
    ops.brightness = 50

    matrix = RGBMatrix(options = ops)
    font = graphics.Font()
    font.LoadFont("../../../fonts/7x13.bdf")
    
    red = graphics.Color(255, 0, 0)
    graphics.DrawLine(matrix, 5, 5, 22, 13, red)

    green = graphics.Color(0, 255, 0)
    graphics.DrawCircle(matrix, 15, 15, 10, green)

    blue = graphics.Color(0, 0, 255)
    graphics.DrawText(matrix, font, 2, 10, blue, "Text")

    time.sleep(10)

```

> if **name** == “ **main** ”:  
> ledtest = LEDTest()  
> if (not ledtest.process()):  
> ledtest.print\_help()

I run this using:

> sudo python LEDtest.py

but get the following error message: “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”

Clearly, I am running as root so not sure what the problem is. The code runs but as warned the image is noisy and flickering. I am very new to python so apologies if I’m overlooking something simple.

Thanks

---

<div class="post-metadata">

**Author:** ![Jmc](https://avatars.discourse-cdn.com/v4/letter/j/e36b37/32.png) [@Jmc](https://rpi-rgb-led-matrix.discourse.group/u/Jmc)\
**Post date:** [August 19, 2021, 11:05am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-error-when-changing-board-options-python/306/2 "2021-08-19T11:05:21Z")

</div>

I should mention that if I replace the line:

> matrix = RGBMatrix(options = ops)

with

> matrix = self.matrix

then the error goes away, but obviously the option changes aren’t applied
