Episode: 2089
Title: HPR2089: Solving a blinkstick python problem
Source: https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr2089/hpr2089.mp3
Transcribed: 2025-10-18 14:09:49

---

This is HPR Episode 2089 entitled, Solving a Linkstick Pison Problem.
It is hosted by MrX and in about 20 minutes long, the summary is, how I solve the problem
I found when trying to control my new Linkstick Anno with Pison.
This episode of HPR is brought to you by an honesthost.com.
Get 15% discount on all shared hosting with the offer code, HPR15, that's HPR15.
Get your web hosting that's honest and fair at An Honesthost.com.
Hello and welcome hacker public radio audience, my name is MrX and this is my 13th HPR podcast.
Today's programme is going to be about a problem I encounter while trying to install a
Linkstick and using it in Python. But before I get onto that, I'd like to start by thanking
the people at HPR for making all this possible. It's really a great service and really
easy to use. Just pick up microphone, hit the record button, record something and send
in the show. It's really been streamlined that the process, it's just go to the upload page
and it's really a delight. The hardest problem is getting down to writing the show notes but
even then it's no big deal. If everyone contributed, we'd have loads of shows so why don't you
give it a go? You might find you actually enjoy it.
This came about because I was listening to an HPR podcast by our Mr Ken Fallon speaking
to Dave Morris and he was counting that he'd purchased a Linkstick. In fact, he started
speaking about the Linkstick, I wasn't even sure what the heck it was. I think it was
actually Dave Morris had done an HPR podcast further back. In great detail, as Dave always
does, I had a wee look back at his notes and they were just fantastic. The detail
that Dave goes to is just phenomenal. I'm afraid that there's no way I can match that
level of detail. I don't have the time and I was just used to do that. I must apologise
for that. I'm listening to Dave and Ken talking. It's just a real joy, a delight to listen
to him. I've got a real natural rapport, so to speak. Anyway, a Linkstick is in a
no expert before I start speaking, but a Linkstick is, it seems to be a wee board that you
can plug into a USB stick. A USB port, I should say, on a PC. It's got a, I think, some
sort of RGB LED, which you can control and it can be turned red, green, blue, or you can
mix the colours and whatnot. I kind of described what it was and I thought, that's just the
sort of thing I'm looking for for a project I already have on the go, which I plan to
talk about at some point, but I haven't got around to. As I said, I'm not a professional
programmer and some of the ideas and things I've just picked up by reading stuff for
the internet to solve this problem. In some of the concepts and stuff, I don't necessarily
fully understand or may have gotten wrong, so I'll just start by saying that before going
further and maybe a mileage all will vary. So I've got the, the, the, the, the Linkstick
arrived in the post and I got the, the Linkstick Nano, which is really tiny, previously I would
have, and I had a bit more time in my hand, I would have, what the, the standard Linkstick
and, um, attached to components, it would have been nice to be fun, soldering, exercise,
but, uh, I don't have so much time these days, so I've, I've plumbed for the, um, this
sort of pre-built, uh, Linkstick Nano, plus it's a bit smaller and a bit tidier and there's
not enough a lot of room around the project that I'm using it with. I wanted something
small and compact, hence why I went for the, but the Linkstick Nano. There's a whole
series of, uh, Linkstick devices, um, some in the shape of a ring, um, some in a square,
some in a stick shape with multiple LEDs, um, uh, there's all, there's all, whole, whole
host of them. And of course, they're running Windows, Mac, Linux, Raspberry Pi and all
these sort of things. And, uh, it, it can be, uh, controlled from the command line, um,
when you install the software or via Python, uh, so my plan was to use it in Python, but
might also use it in some bash scripts as well, or some ideas for that too. But, uh, I followed
the, the standard, um, seven instructions for installing, um, the Linkstick software.
And it goes something like this, you, you do, uh, pseudo space at dash gate, space install,
space dash y, space, space Python dash pip, and space Python 2.7 dash dev. The Python 2.7,
well, let's, let's, uh, the Python pip, uh, I believe it's a, uh, a package management
system, which, um, was introduced, um, I think it was introduced, I think if I remember
right, looking at the notes, it was just in 3.2 or 3.4 version of Python, but, um, it, uh,
it can be shoehorned into other versions, but, um, anyway, that, that, of course, the,
the Python 2.7 dash dev, I wasn't sure whether I needed that because I've already got, uh,
Python, uh, on my machine now, I was installing it on a Raspberry Pi, I didn't mention that.
And, um, but I thought, well, if it's already installed, I don't know what we can, any
difference, I'll just say, well, it's installed already, don't, don't need it, you know,
so I ran that and, uh, I think it maybe installed 40, 50 megabytes of stuff, so I don't
know what was all going in there, didn't, didn't really check. I was just eager to get the
thing going as you do, you know, I was in a bit of a, a bit of a rush. So then after
doing that, a, I did pseudo space, pip, space, install, space, blink stick. So that invokes
the, the Python package manager, which you've just previously installed and installs the
package, blink stick. Now, I think it's, I think it essentially installs a module
blink stick, um, a plastic command line tool, which allows you to, uh, use it with bash
scripts and such like. So, uh, after doing that, I dropped a terminal and I did pseudo space,
blink stick, space, dash info. And when you run that, it, uh, looks to see if there's any
blink sticks attached to your, um, hardware and reports them. And in this case, it did, so
that's great. The software's working. That's fantastic. Just what I'm looking for. Of
course, to use that, you've got to use a pseudo command. Now, the final command I, I did
was I used, now, it's actually written here, blink stick, but it must have been pseudo. So
it's pseudo space, blink stick, space, dash, dash, add, dash, you dev, dash, rule. And what
that does is it, um, it adds a, you dev rule so that you don't need to issue pseudo anymore.
Um, so that's, that's quite handy. And I ran that and then I should not have found it. I
could just do blink stick, dash info, for example, and it just worked or other commands
as such. So, so that that all seemed to work. Find out that it's great. I have a, a, a
Python script, which I run on this project, which I'm not going to describe to you because
I see I'm going to talk about it another time. And it's a, I don't know, there's a few
hundred lines of Python code, whatever I can remember. And, uh, to use it, to use the
blink stick in Python, you just import the, the blink stick module and you use the command
from blink stick, import, blink stick or something like that. It's a standard way of doing
things. Uh, but anyway, when I did that, I found that, um, tried to run the, um, the
Python script that came back with a complaint that it couldn't find the, the module blink
stick. And I couldn't quite understand that was bit curious. So I, I quit out the, um, script
and went into the Python interpreter, which you can run just by typing the word Python
at the command line. And then I entered help, uh, space modules. I don't know, this whole
panel modules and one of the modules was, uh, blink stick. So I don't know that's there.
So that confused me a little bit. And then I ran, um, is it help, space, modules,
much, so help space module, space, blink stick, I think it was something like that. Uh,
the, the help system tells you how, I don't use the help system very often as you can tell
what I'm saying here, even though I'm writing a couple of hundred line of, just, of Python
script, I haven't really lubed it for a while and I'm a bit rusty now. Um, but it's something
like help space, module space, blink stick. And it gives you a bit like, look, a bit
of a, a man page that tells you a bit about that module. And it said that the, the module
was located in slash user slash local slash lib slash Python 2.7 and then something else
had to that. And I had a, a check and sure enough when I went to that directory, the module
appeared to be there. So that again, I was even more confused. Well, why is it not working?
And I just make sense. And, uh, I hunted it around and internet and I wanted to reach
the checks and trials. I didn't get anywhere. I, I, I dropped out of the help and tried,
because you can, you can enter commands from the Python interpreter. So rather than a script.
So I tried, um, importing the module, blink stick at the Python interpreter. So I just typed
import, uh, from, from blink stick, import, blink stick or something like that. I can't
remember. But basically when I did that, there was no error. And that surprised me.
And I tried to issue a few commands, a few the, I don't like to find out information to query
if I was in the blink stick sound. And that responded fine as well. So I thought, how can
it be working okay on the interpreter, but it isn't working no key with my script. That's
confusing. So how, how is that? Then I thought, well, maybe it's working with the wrong
version of Python. Maybe I can force it to work with a different version of Python. So I had
a look at the first line of my script and slat. And then I, of course, I then realized
it said, uh, Shabang, um, just like standard, um, script starts with a hash. And then
a exclamation mark slash bin slash Python three. And I thought, ah, I installed my, uh,
the blink stick to Python 2.7. Uh, so that was what was causing the problems. So I, um,
and I, I've been doing a bit of reading and I found that if you refer to Python three, then
it's all variance while it's up to the latest version you're using. So I actually have the latest
version I've gotten my, um, Raspberry Pi is 3.2. So although it says slash bin slash Python
three, it would really been working Python 3.2. So I changed that from, um, at least that's
my understanding. So I changed that to slash bin slash Python 2. I thought that's great.
That'll run Python 2.7. And I ran that. And because I've got a whole pile of errors. And I'd
kind of forgotten that a good while ago, I, I changed from 2.7 to 3 or whatever and, and
re-formatted the script so that it, because there was some differences in incompatibilities
so that it would, um, work. And I thought, oh, I can't, I'm not going to go down the route
to doing that again. I really want to stay with, with, uh, 3.2. Um, so I thought, well,
I thought, well, I've got to really install PEP and, uh, blink stick for Python 3.2. So
I think what happens is that there's a, there's a, there's a, there's a, a default system
wide. Often your, your, your Linux distribution has a, has, is using Python. And there's a
system wide default Python. And in this case, my system default is 2.7. And so that,
some, some, some of the tools your Linux distribution, let's repair this, we should maybe
use a Python for various things. And so you don't really want to be messing
about changing your version of your default version. Um, so that's why I can have multiple
things on your system. I just say, I'm all a little bit sketchy about all of this. But
anyway, the solution would be to install PEP, um, I've, I've, and blink stick for version
3.2. Um, so to get that working, what I did was I should be following commands. Um, and
use the, the tab completion feature, uh, to great effect, to see what kind of packages
were actually available. So I did, uh, pseudo space app dash gate. That's quite straightforward.
Space install, uh, dash Y, um, space, uh, Python 3. And what about the Python 3? I then
hit the tab key. And I think I said something like, do you want to see the couple hundred
things for that? And found that there was a Python 3 dash pip. So what that means that
will install in Python 3 for all variants, or for the latest variant of Python, which you
have in your system. And in my case, that's Python 3.2. So again, it's pseudo app gate install
dash Y, Python 3, dash pip. So that installs PEP for Python 3.2. So next, I used the tab
completion again, um, to find out what package were available. And did, um, pseudo space
PEP and hit the tab key. And found there was a whole pile of PEP says PEP in its own, which
installs it to the standard default Python you've got running on your system. And Mike is
I think I had a Python dash 2.7, uh, Python 3.2. And I think I had other ones that did
have 2.6. I can't remember. I had a few actually. Um, so of course I, I chose 3.2, so
pseudo space, uh, pip dash 3.2 space install space blank stick. So that's using the Python
package manager pip to install, um, blank stick. And it's a package manager for Python 3.2.
Uh, so once that was done, I ran blank, blank stick dash info and up came, um, the information
about the attached blank stick. And of course, um, you've already applied the UDF rule when
you want it, because I had installed it for the 2.7. So I didn't need to repeat that, that
command, um, and then that was it. So I think, uh, kind of understanding how, how modules
and different versions of Python work is all a bit of a blackout. Um, I just said before,
I'm not a professional programmer. And, uh, I find that topics like, um, object orientation,
certain things like that, a bit of a, a bit of a blackout, really, and, uh, some of the
concepts can be a bit difficult to get your head down. So I understand this, this, this
pip package management thing for Python, um, was brought in to try and simplify adding modules
to your Python. As yet, I haven't added many extra modules. The, the set of modules that
come with Python is, is really extensive and I haven't actually needed to install many
modules. I think when I first started looking at Python, you just did it manually and you
just just moved the modules into the right, right location. And that was the other thing.
I had a, I had a reluca, um, if you issue this, uh, if you import a module called CIS, so
it's import space CIS, either in a script or at the command interpreter, and then after
that type, CIS dot path, that will display, um, all the paths that Python will look through,
uh, for its system files, modules and such like, uh, I think I did that early on as well to
see if, um, they're the path to the modules where it were included. And of course they were,
which confused me as well. Um, but yeah, I think I'll find Python in a fantastic language
to, to, to work with when I got a chance. I say these days, my time's a bit limited, so, um,
don't get much for chance these days, but, um, hopefully this will solve a, solve a problem
if you come across it, the same problem it will solve it for you, save you a bit of time.
And if not, maybe I'll just be a bit of interest, you'll be back in about how Python organizes
things and whatnot. If I've left anything out, I've got anything wrong, feel free to let
me know, you can maybe add it in just comments or whatever. Um, I'm not at all confident
in what I'm saying here, but, uh, hopefully I've got it right. But, um, anyway, I hope you
enjoyed this podcast, this episode, and, um, I think that's about it. So just, so, uh,
if, if you want to contact me, I can be contacted at mrx at hpr at googlemail.com,
so until next time, thank you, and goodbye.
