Attribute Error Unicron pHat


#1

So i have been trying to figure out my unicorn pHat the a while now with no luck. I have downloaded the files with curl https://get.pimoroni.com/unicornhat | bash then used sudo python and then type import unicornhat as uh. It all works fine to that point but then when i put in uh.set_layout(uh.PHAT)
as the tutorial shows it comes up with this “Traceback (most recent call last):
File “”, line 1, in
AttributeError: ‘module’ object has no attribute ‘set_layout’” I have tried doing import uh.set_layout but that didn’t work. It is probably completely wrong as I would still call myself a beginner. I am using python 2.7.9 and am on a raspberry pi 2 model b running raspbian jessie. I would really appreciate help and I will say a thank you in advance.


#2

Could you post your complete code? Use backticks to preserve formatting, like this:

```
formatted code goes here
```

If you’re using a REPL/Command Line and typing Python code line-by-line you can use dir(uh) to see what methods exist, and get an idea if something’s gone awry.


#3

Don’t worry, I think I’ve solved it. I was using the wrong python and I need to use python 3 (it didn’t say which one to use). But thank you for giving me the info for the code. It will be very handy in the future. Thank You