Importing Unicornhat library causes code not to run?


#1

I have installed the unicorn hat library’s using the one line installer but whenever I try to import it into a python script it causes a restart.

Why is this happening and how do I stop it?


#2

you would need to start idle with elevated privileges, from the command line:

sudo idle3

… this is because unicornhat needs root access to drive the hardware.


#3

Everything seems to need elevated privileges


#4

it depends what you are referring to… in term of Pimoroni libraries, no, unicornhat is in fact the only one at this point to require low level access (though it used to be true around 2 years ago for many others).


#5

May I ask why unicorn hat requires elevated prevaledges?


#6

It needs to write directly to the PWM hardware and DMA to allow real-time control of the WS281x ‘pixels’. Or rather that’s the job of the underlying 3rd party library (written in C - most notably to allow refined and accurate timing).