RPi.GPIO error

June 1, 2024, 07:58

blitzspawnz_

Hi, So I have an issue with rasp pi. I updated and installed the RPi properly, but it still gave me an error when I used python/2/3 [filename] to run the code. The error This module can run only on raspberry pi! Can anyone please help me? Thanks in advance

dailytinker

yo

blitzspawnz_

Hiiiii

dailytinker

I think ik fix

blitzspawnz_

Oh great

dailytinker

what is your python version

blitzspawnz_

I used 3

dailytinker

do python -v

blitzspawnz_

But like I tried python, python2, and python3 but they don't work as well

dailytinker

try this
apt policy python-rpi.gpio

blitzspawnz_

Gimme a sec, not on my laptop now

dailytinker

does it have wifi

dailytinker

you should download zerotier

dailytinker

then you can connect to your rpi where ever you want as long as thaT device you are using to access the pi on has ZEROTIER unless local

blitzspawnz_

It's a rasp 4, not sure though cos it's from a friend's friend so I dont want to break it ...

blitzspawnz_

Oh I find it interesting that if I connect it to my laptop beforehand it has its own vm, maybe it should work from the microsd

blitzspawnz_

nvm.... it's the vm I uploaded myself lol

blitzspawnz_

<@675227360965951498> sorry for the ping bro but it said that I have none rpi installed

blitzspawnz_

maybe I should install it manually

dailytinker

hmmm

blitzspawnz_

my sudo mv won't work, lemme try it again

dailytinker

you fucked somethin up

blitzspawnz_

shouldn't be the case

blitzspawnz_

just saying that it''s not a dir, but I made a dir for it

blitzspawnz_

how would you install the RPi.GPIO friend?

dailytinker

idk exactly

blitzspawnz_

but you can run gpio just fine?

dailytinker

i havent ever used gpio

dailytinker

ive been with someone that has but ive never ran it myself

blitzspawnz_

I did check on that, didn't work either...

blitzspawnz_

I think the main problem is in the sudo apt install, it wasn't able to find RPi

blitzspawnz_

Guess it's a file dependencies problem, will look it up later... for now I rest....

blitzspawnz_

Thanks a lot guys

oops.se

No need to use curse words!

thunder07337

Here you have an answer: https://forums.raspberrypi.com/viewtopic.php?t=359742 It will never work on Pi 5 and later unless the creator reprograms his stuff. So everything that uses rpi.gpio does not work on Pi 5 and later.

blitzspawnz_

I have pi 4

blitzspawnz_

I found a solution but haven't tried, installing the dependencies first. Will maybe try tomorrow, thanks for your help

thunder07337

cat /etc/os-release

blitzspawnz_

This is to check the raspbian OS?

thunder07337

Version yes

oops.se

Raspbian OS is OBSOLETE!

xkevinfpx

<@1005770488242524201> solved?

blitzspawnz_

Not yet, will solve soon

blitzspawnz_

<@543079039628214272> I have another error : "This module can only be run on a Raspbery Pi!" byut I already connected my pi

blitzspawnz_

still won't work.....

xkevinfpx

<@1005770488242524201> what python version are you using?

blitzspawnz_

I used all of em and still wouldn't work, but mainly 3

blitzspawnz_

should I manually install RPi.GPIO?

blitzspawnz_

I tried a script for printing and it works just fine

blitzspawnz_

sorry for the ping , with pip3 it's installed fine but I can't access RPi.GPIO. do I need to connect it to pins and leds first just to upload the code? <@543079039628214272>

xkevinfpx

wait haha

blitzspawnz_

don't worry, take your time

blitzspawnz_

may I dm you?

blitzspawnz_

my main error is that it's "not connected to a pi!"

xkevinfpx

you could, but then other people dont know what you had done

blitzspawnz_

ah true

xkevinfpx

So you did this?
pip install RPi.GPIO

blitzspawnz_

yeah it's working fine

blitzspawnz_

I have like 2 main errors, either the "not connected to a pi!" one or "RPi.GPIO not found"... confusing....

xkevinfpx

when do the errors occur?

xkevinfpx

when you start your script?

blitzspawnz_

when I do python3 [filename]

blitzspawnz_

yeah

blitzspawnz_

lemme try it again this time

xkevinfpx

could you share a screenshot of the whole error if it occurs?

blitzspawnz_

but the rule doesn't allow screenshots here.... that's why I proposed dms

xkevinfpx

yea okay then dm

thunder07337

Which OS version are you running? Maybe it's the latest version (bookworm), and you have to go back to Bullseye...

blitzspawnz_

I use Bullseye

thunder07337

Have you tried the following commands?
sudo apt update
sudo apt -y install python-rpi.gpio
Or
sudo apt -y install python3-rpi.gpio

blitzspawnz_

My main problem is that the package is not found, will try -y

thunder07337

But you see that my suggested commands use apt and not pip? And that python-rpi.gpio is installed and not rpi.gpio? That does make a difference...

blitzspawnz_

I did the pip one and it was installed fine, but when I can't access gpio when used. Haven't tried -y though

thunder07337

-y only means that it should not ask if you want to install it, so this will not bring any change. Either it doesn't work because of pip or because python-rpi.gpio is missing, because you only have rpi.gpio installed...

blitzspawnz_

so what should I download for gpio? RPi.GPIO won't work

blitzspawnz_

is rpi and RPi is different?

blitzspawnz_

I think I need to download other packages but don't know what

blitzspawnz_

still having issues, may I dm you? <@1187039958561726494>

thunder07337

No, 1 no time, 2 I have no idea, I just sent them a solution from the Internet. 3 I don't like private conversations.

blitzspawnz_

noted