Guide by Tim; Control Multiple Fully-Addressable WS2812B RGB LED Strips with a Raspberry Pi Single Board Computer

Hi Bryan!

I’d try running this code:

sudo apt install --upgrade python3-setuptools
sudo python3 raspi-blinka.py

Then the commands in the guide:

sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel
sudo python3 -m pip install --force-reinstall adafruit-blinka

Let us know how you go!
Liam

2 Likes

Thanks Liam!

When I ran sudo apt install --upgrade python3-setuptools I got:
python3-setuptools is already the newest version (33.1.1-1)
python3-setuptools set to manually installed
0 upgraded, 0 newly installed, 0 to remove and 482 not upgraded

Then when I ran sudo python3 raspi-blinka.py I got:
python3: can’t open file ‘raspi-blinka.py’; [Errno 2] No such file or directory

Obviously the next two commands didn’t work from there. Thank you for any other suggestions!

Hey Bryan,

Sounds like you’re in the wrong directory, what do you get when you run these commands?:

pwd - Print Working Directory
ls -la - List Directory (list all)
locate raspi-blinka.py - Locate File

You’ll need to use cd (Change Directory) followed by the path to the folder containing raspi-blinka.py in order to use python3 raspi-blinka.py

2 Likes

pwd gives me:
/home/pi

ls -la gives me a bunch of lines of directories

locate raspi-blinka.py gives me:
bash: locate: command not found

When I try to run:
sudo apt-get update
or
sudo apt-get upgrade

I get a bunch of lines stating “temporary failure resolving archive.raspberrypi.org” I imagine this is the root of these issues. I am using my phones hotspot since the school’s WiFi I use tends to block a lot of downloads. Should I reimage the SD card? I appreciate all of the help and the patience!

Hey Bryan,

No worries, happy to help!

Sounds like you’re just in your home directory (ls probably would have listed Desktop, Downloads, Music, Documents, Video, etc.), we need to work out where raspi-blinka.py was downloaded in order to run it from a terminal. How did you download it originally?

I get a bunch of lines stating “temporary failure resolving archive.raspberrypi.org

Yes, that’s usually due to the Pi not having a network connection. It is called resolving as your operating system (well an application within the OS) is trying to ask DNS servers on the network what IP address it should use for archive.raspberrypi.org in order to check for updates. i.e. what the URL should resolve to (for me, it resolves to 176.126.240.167 although it may be different for you based on region, etc.).

archive.raspberrypi.org definitely exists, I’d double check you’ve got an internet connection for your Pi.

Since you didn’t have the package with the locate tool installed, you can instead use this command to try and locate the raspi-blinka.py file:

find . -name "raspi-blinka.py" -print 2>/dev/null

The 2>/dev/null at the end will just filter out any Permission Denied errors from the output to tidy it up. You can run it without that if you’re curious.

2 Likes

Made some progress today! Here are some things I had to do first:

  1. Simple one. My time zones were not correct which was affecting my ability to access the internet.
  2. I had to update my source.list entry by using:
    sudo nano /etc/apt/sources.list
    and replaced the top line with:
    deb Index of /raspbian/ stretch main contrib non-free rpi
  3. This allowed me to successfully run:
    sudo apt update
    sudo apt full-upgrade
  4. From there I ran:
    sudo apt install --upgrade python3-setuptools

All of that ran successfully, but I ran into an issue when I ran:
sudo python3 raspi-blinka.py

Here’s what I get:
File “raspi-blinka.py”, line 94
shell.run_command(f"{pip_command} RPi.GPIO", run_as_user=username)
^
SyntaxError: invalid syntax

Any suggestions on fixing that?

Also when I ran the find . -name “raspi-blinka.py” -print code it came back with:
./raspi-blinka.py

THANK YOU!

2 Likes

Hey Bryan,

Fantastic, seems we’re nearly there now. This is an error within the raspi-blinka script itself. That find command you ran returning ./raspi-blinka.py means that it is in the same directory as your working directory (i.e. . that you specified in the command).

I’d reckon you’re missing some required packages or permissions, which would be why shell isn’t being recognised by your python interpreter. Possibly because you need to activate a Python virtual environment or run the code with a certain usergroup available such as sudoers.

Can you please link to the code you’re using? It’s interesting that the function call is shell.run_command( usually the os or subprocess modules are the preferred way to execute a process within a python script.

1 Like

I am using the information from: Installing Blinka on Raspberry Pi | CircuitPython Libraries on Linux and Raspberry Pi | Adafruit Learning System

No matter which method I try, I seem to be getting errors (syntax or other wise). Would you be able to let me know what packages or permissions I would need to add/modify?

I assume I’m not to change the code in raspi-blinka.py. I’m not sure how to proceed from here. Many thanks if you are able to help some more!

Interesting enough, when I tried running:
sudo pip3 install rpi_ws281x adafruit-circuitpython-neopixel

I got a different error then before:
Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-lym5cwk3/sysv-ipc/

Before I was getting this error:
python3: can’t open file ‘raspi-blinka.py’; [Errno 2] No such file or directory

Sanity check time. I know it might be obvious but I can’t see the question asked anywhere else - are you running at least the Bullseye version OS or later?

Thank you for the sanity check…I was running Stretch… Instead of updating to Bullseye, I am going to grab a new SD card and start from scratch with Bookworm. With Bookworm, I should be able to just run these lines to get up and running correct?:

sudo pip3 install rpi_ws281x
sudo pip3 install adafruit-circuitpython-neopixel
sudo python3 -m pip install --force-reinstall adafruit-blinka

2 Likes

yes! I’d expect things to be much simpler from here :smiley:

2 Likes

Hi! Excellent guide. I tried on rpi4 with no issues at all. Just tried it on rpi5 and got this when trying to run the one strip script:

Traceback (most recent call last):
File “/home/robot/ledstrip/OneStripNeopixel.py”, line 16, in
pixels1.fill((255, 255, 255))
File “/usr/local/lib/python3.11/dist-packages/adafruit_pixelbuf.py”, line 216, in fill
self.show()
File “/usr/local/lib/python3.11/dist-packages/adafruit_pixelbuf.py”, line 204, in show
return self._transmit(self._post_brightness_buffer)
File “/usr/local/lib/python3.11/dist-packages/neopixel.py”, line 180, in _transmit
neopixel_write(self.pin, buffer)
File “/usr/local/lib/python3.11/dist-packages/neopixel_write.py”, line 42, in neopixel_write
return _neopixel.neopixel_write(gpio, buf)
File “/usr/local/lib/python3.11/dist-packages/adafruit_blinka/microcontroller/bcm283x/neopixel.py”, line 66, in neopixel_write
ws.ws2811_channel_t_gpionum_set(channel, gpio._pin.id)
TypeError: in method ‘ws2811_channel_t_gpionum_set’, argument 2 of type ‘int’

Any ideas or guidance? THANKS!

Hi guys, why can’t i download adafruit-neopixel and adafruit-blinka. i have already updated all. Many thanks.

sudo apt install rpi_ws281x python3-adafruit-circuitpython-neopixel
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
E: Unable to locate package rpi_ws281x
E: Unable to locate package python3-adafruit-circuitpython-neopixel

Hi @Dat272762 ! Welcome to the forums :slight_smile:

The error message you’re seeing indicates that the package management tool “apt” used in Linux distributions cannot locate the packages rpi_ws281x and python3-adafruit-circuitpython-neopixel.

Here are a few potential reasons and solutions:

  1. The packages might not be available in the repositories that are currently in your sources list. To resolve this, you can try to add the relevant repositories to your list and then update the list.
  2. These specific packages might not be available via apt. They should be installed via pip, Python’s package installer, as they are Python libraries. Ensure pip is installed (you can install it via sudo apt-get install python3-pip), and then try:
  • sudo pip3 install rpi_ws281x
  • sudo pip3 install adafruit-circuitpython-neopixel
  • sudo pip3 install adafruit-blinka
  1. Check if these packages are available for your specific version of the distribution.
  2. The dash (-) and underscore (_) in package names can sometimes be mixed up. Try both versions when you’re searching for a package.
  3. Try updating your package list first with sudo apt-get update, before running the install commands again.

Always remember to check the official documentation for correct installation instructions for the packages you’re trying to install.