Unicorn Hat Not Working - Python syntax errors

Hi,

My friend and I are attempting to get his Unicorn Hat working, with no luck. We’ve updated Raspbian, run curl https://get.pimoroni.com/unicornhat | bash, and followed the steps in multiple tutorials. We seem to be having an issue - problem is we’re not sure if it’s a hardware issue, a software issue, or PEBKAC.

When we use terminal to run sudo python ./simple.py it runs with no visible errors, but nothing actually happens on the unicorn hat. No lights at all.

When we attempt to run a program such as
import colorsys as col
import unicornhat as uh

def set_pixel_hsv(x, y, h, s, v):
r, g, b = [int(x*255) for x in col.hsv_to_rgb(h,s,v)]
uh.set_pixel(x,y,r,g,b)

we get the following error

%Run unicornhat.py
File “/home/pi/unicornhat.py”, line 29
)import unicornhat as uh
^
SyntaxError: invalid syntax

Looking at unicornhat.py, it shows:
)import unicornhat as uh

uh.set_layout(uh.HAT)

We’re a bit stumped as to how to proceed with this. Any help would be appreciated!

Thanks
Meredith & Billy

Are you using a Unicorn HAT, or a Unicorn HAT HD? They require different software, which may be causing you woes!

Your “SyntaxError” is due to an erroneous “)” before the “import unicornhat as uh”. You’ll also find that if you name your test file “unicornhat.py” and then try to “import unicornhat” the script will simply import itself instead of the Unicorn HAt library and fail miserably.