• Traceback (most recent call last):
  • File “”, line 8, in <module>
  • GPIO.setup(pin1, GPIO.OUT)
  • RuntimeError: No access to /dev/mem. Try running as root!


Add your user to the gpio group: đź“‹ Copy to clipboard⇓ Download

  • sudo usermod -a -G gpio $USER

then log out and log back in (or reboot, if that doesn’t help).

The reason for this error is that /dev/gpiomem is only accessible by users belonging to the gpio group. By default, only the pi user belongs to the gpio group – hence, if you run a script as any users other than pi or root, you will see that error message.

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *