adafruit / Adafruit_CircuitPython_INA260

CircuitPython driver for the TI INA260 current and power sensor
MIT License
14 stars 11 forks source link

Installing the Library on my pi5 bookworm breaks my python GPIO calls #29

Open quitmeyer opened 6 days ago

quitmeyer commented 6 days ago

For my project we have a relay hat on the pi that is controlled by python code.

I use it with a pi4 and a pi5. If i install the INA260 library on the pi4 everything is fine.

if I install the INA260 library on a pi5 like this:

sudo pip3 install adafruit-circuitpython-ina260 --break-system-packages

(using the break packages flag was the only way i could figure out how to get it installed)

immediately the GPIO stops works and i get this error

Traceback (most recent call last):
  File "/home/pi/Desktop/Mothbox/TakePhoto.py", line 54, in <module>
    GPIO.setup(Relay_Ch1,GPIO.OUT)
RuntimeError: Cannot determine SOC peripheral base address

now the pi5 does have weird stuff with its GPIO pins, and this error comes up for instance if using the regular GPIO libraries. and so in the past i got around it by installing the lgpio library.

but now it doesn't matter if i have the lgpio library or not, whenever the ina260 library is installed it permanently breaks the setup.

also i cannot do pip3 uninstall either. it keeps it being broke. I have to flash a new image.

quitmeyer commented 4 days ago

i found an idea for a way to hack around it from chatting over here: https://forums.raspberrypi.com/viewtopic.php?p=2232912#p2232912

I went into


cd /usr/local/lib/python3.11/dist-packages/RPi

and just started deleting stuff until the GPIO pins started working again.

this meant deleting

sudo rm _GPIO.cpython-311-aarch64-linux-gnu.so

pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi $ cd GPIO
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi/GPIO $ ls
__init__.py __pycache__
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi/GPIO $ sudo rm __init__.py
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi/GPIO $ sudo rm * -r
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi/GPIO $ cd ..
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi $ sudo rm __init__.py
pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi $

it looks like you only need to delete this though:

pi@mothbox:/usr/local/lib/python3.11/dist-packages/RPi $ sudo rm __init__.py 

Obviously im not the smartest hacker out there, but hey it works fine now it seems!