Fan shim libraries don't seem to recognize Raspberry Pi

Hi there,

I’m not terribly experienced at Python programming, but have plenty of experiences of other languages.

I’ve installed the software to interface with the Pimoroni fan shim on a Raspberry Pi 4. I installed it first via pip, but that seems to give you just the libraries and not the examples, so then I fetched those using git.

My problem is that none of them wants to run - they all complain that they’re not on a Raspberry Pi! My first thought was that the software didn’t yet recognize the Pi4, but surely the fan shim is a Pi4 product?

The error message is as follows:

john@pi4:~/Work/fanshim-python/examples $ python 
Traceback (most recent call last):
  File "", line 6, in <module>
    fanshim = FanShim()
  File "/usr/local/lib/python2.7/dist-packages/fanshim/", line 30, in __init__
    GPIO.setup(self._pin_fancontrol, GPIO.OUT)
RuntimeError: Not running on a RPi!
john@pi4:~/Work/fanshim-python/examples $

Any ideas?


Try running the examples in python 3 / idle 3.

Thank you. Tried that - same result.

Ok was worth a shot. Did you do pip or pip3?
The fan shim is on my wish list, haven’t ordered one yet though.
I have a Pi 4B ordered, hasn’t shipped yet though. It will be a week to 10 days before I see it once it does ship.
I’ve downloaded Buster, haven’t installed it on any of my Pi’s yet though. Was going to wait for my 4b to arrive first.

The easiest way to get the fanshim running is to do the git clone install, then cd into examples, then sudo ./

Done that, but I suspect it’s not working. The process is there, but the fan runs all the time, regardless of temperature.

That’s why I tried running the examples, all of which fail to run. I suspect the daemon process is having the same problem with the library functions not working.

To alphanumeric - I used pip, as per the instructions. Invoking the examples with python3 does seem to cause them to pick up a different version of the libraries, but there’s the same “Not running on a RPi” error.

Ok, I’m far from being any kind of expert on this but I believe pip sets up for python 2 and pip3 sets up for python3?. I usually run the one line installer, when available, and run the examples on python3.
It’s sounding like your issue isn’t that though? I’m not skilled enough to figure out what’s gone wrong.

If it was me, with my skill level I’d just bail and start with a fresh Buster image. Maybe even download a new image in case what you have is corrupted or something. Then run the one line installer and see if you get that same error.

I solved it.

The problem is one of permissions - you need to be a member of the gpio group before you can run the examples. The error message is just plain wrong.

Thanks for all your suggestions - they did push me in the right direction.

1 Like

From what I’m seeing on the Pi Foundation forum, Buster has a few issues. And they are working to clean them up. Not releasing Buster would mean delaying the Pi launch so I can see why things went the way they did.
I’m guessing your issue is related to that? It kind of sounds like it anyway. I won’t have my 4B for a week or more so hopefully a lot of the glitches get cleaned up by then. I think I’ll wait a while before trying Buster out.

It probably wouldn’t hurt to run sudo apt-get update, sudo apt-get upgrade. If you haven’t aleady done it. Maybe even once a day for a while.

I think I’m having a similar issue but i’m not sure, i followed the instructions to install the fan but it doesn’t seem to run the service on start up and the LED isn’t responding to on/off states at the moment. I don’t have any coding experience so I can’t be sure what the issue is. I can run the test scripts from the git page and they work fine though.

Thank you jhwinters, I was getting the same error when trying run the service as a new user pimoroni that I’d created, but it worked perfectly if you ran it as pi or root. Didn’t really want to run the service as root, which is how it installs itself, so thanks a bunch!

for others having the same problem:

sudo usermod -a -G gpio YourUserName

Ah this appears to be going down the right route for my problem - no matter what i’ve tried i can’t seem to make it change from:

Setting up with:
Threshold: 36 C
Hysteresis: 2 C
Delay: 2 seconds
Preempt: no

Even if i alter these suggestions:

To change these options, run:
sudo ./install-service --threshold <n> --hysteresis <n> --delay <n> (--preempt)

Or edit: /etc/systemd/system/pimoroni-fanshim.service

Was wondering if it’s a permissions thing but unsure how to change it. Any ideas anyone?

Hey supert3d,

Not sure where that Setting up with: bit you’ve quoted is coming from. if you run htop this should show you the exact command that’s being run, for example mine is:

python3 /usr/bin/fanshim-python/examples/ --threshold 50 --hysteresis 2 --delay 2

I don’t think this has anything to do with permissions for you, it’s the command being run which is determined by /etc/systemd/system/pimoroni-fanshim.service. Mine looks like this:

Description=Fan Shim Service

ExecStart=/usr/bin/fanshim-python/examples/ --threshold 50 --hysteresis 2 --delay 2


So if you

sudo nano /etc/systemd/system/pimoroni-fanshim.service

and change ExecStart= to your desired parameters this should do the trick. Note you’ll need to either reboot or

sudo systemctl daemon-reload
sudo systemctl stop pimoroni-fanshim
sudo systemctl start pimoroni-fanshim

Now if you run htop again you should see the command has changed.

Brilliant, that worked. Really appreciate the time it took you to reply - that helped a lot. When that fan stopped for the first time that was a good moment haha