NeoPixels not working at all (error on Pi)

Hey guys,
I followed the guide as well as I could, but keep getting

    Traceback (most recent call last):
      File "strandtest.py", line 9, in <module>
        from rpi_ws281x import *
    ImportError: No module named rpi_ws281x

Any insights as to what could cause this and how to fix?

Thanks!
-Chris

Hey Chris,

Hmm it seems like our bash script might be playing up a bit!

You can just install that library manually using:

sudo pip install rpi_ws281x

Hope this helps!

Thanks Owen!

I tried running that code but get
sudo: pip: command not found

So I used
sudo apt-get install python-pip

to install pip, but now running your code gives

    Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
    Requirement already satisfied: rpi_ws281x in /usr/local/lib/python2.7/dist-packages/rpi_ws281x-1.0.0-py2.7-                                        linux-armv7l.egg (1.0.0)

and I still get the same result when attempting to run the strandtest.

Just to confuse things futher, I looked in the directory and tried all the other tests, they all get the same result except for lowlevel.py which seems to work, but only on the first 16 LED’s

Hi Chris,

pip may be assigned to the wrong version of python. I can see there are some similar errors in the forum thread for that guide:

We’ll have to have a bit of a dig and see what the root cause is, though I suspect it’s mostly just an issue with python versions.

Thanks heaps for your reply Oliver!

Let me know if there’s anything I can do to help diagnose. I even tried formatting my SD card and running a fresh install of Raspbian, and doing nothing but the guide and still had the same issue so hopefully that rules out anything else I’ve done on this Pi.

1 Like

FWIW, these are the results I got for pip install

pi@raspberrypi4:~ $ sudo pip install rpi_ws281x
Looking in indexes: Simple index, piwheels - Simple index
Collecting rpi_ws281x
Downloading https://files.pythonhosted.org/packages/c2/cf/0c713dcbb08de087619f6f6917cfe68c4ebf6ef828ede4d63a3bf421f1bf/rpi_ws281x-4.3.1-cp27-cp27mu-linux_armv7l.whl (79kB)
100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 81kB 808kB/s
Installing collected packages: rpi-ws281x
Successfully installed rpi-ws281x-4.3.1
pi@raspberrypi4:~ $ sudo python /home/pi/rpi_ws281x/python/examples/strandtest.py -c
Press Ctrl-C to quit.
Color wipe animations.
Theater chase animations.
Rainbow animations.
Color wipe animations.
Theater chase animations.
Rainbow animations.
^Cpi@raspberrypi4:~ $ ^C

The WS281x is in a directory, and the path is in the command line to execute.

Initially, I too had that error, using pip3 install of the rpi_ws281x. The command line must use just β€œpython” as the script downloaded from here is not python3 code.

2 Likes