-2
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(18,GPIO.OUT)
print("LED on")
GPIO.output(18,GPIO.HIGH)
time.sleep(1)
print ("LED off")
GPIO.output(18,GPIO.LOW)

Im̀ trying to proof my rpi pi 5 and i have installed ubuntu 23, and i installed all the necesary lib to use the gpio but the console on the env return

  File "/home/jdam/prueba/prueba.py", line 4, in <module>
    GPIO.setup(18,GPIO.OUT)
RuntimeError: No access to /dev/mem.  Try running as root!

So i don`t understand what is happening,if you could help me that would be wonderful

pd: i am installing tensorflow but i can`t do it because this error:

Building h5py requires pkg-config unless the HDF5 path is explicitly specified using the 

environment variable HDF5_DIR. For more information and details, see https://docs.h5py.org/en/stable/build.html#custom-installation
      error: pkg-config probably not installed: FileNotFoundError(2, 'No such file or directory')
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for h5py
Failed to build h5py
ERROR: Could not build wheels for h5py, which is required to install pyproject.toml-based projects
2
  • 1
    Ask ONE question per post.
    – Milliways
    Commented Apr 14 at 4:10
  • 1
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Apr 22 at 17:19

1 Answer 1

0

You can NOT run RPi.GPIO on a Pi5 because the GPIO is on a different chip which is not accessible via memory.

The best option at the moment appears to be Joan's lgpio although you can use libgpiod which is the officially recommended interface (although poorly documented).

2
  • I believe gpiozero also works.
    – CoderMike
    Commented Apr 14 at 7:51
  • @CoderMike gpiozero 2 uses lgpio as its engine, but as the OP was directly coding with RPi.GPIO this didn't seem relevant
    – Milliways
    Commented Apr 14 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.