-
No access to /dev/mem
Hallo,
ich möchte eine LED zum leuchte bringen und habe mir zum ersten Mal ein Python Programm in SPE geschrieben. Wenn ich das Programm ausführen will, kriege ich folgende Fehlermeldung:
File "/home/pi/LED 01.py", line 1, in <module>
import RPi.GPIO as GPIO
RPi.GPIO.SetupException: No access to /dev/mem. Try running as root!
Was tun?
-
Hey,
hast du das Programm als "root" ausgeführt?
Um auf Hardwarekomponenten wie GPIO, I²C usw. zugreifen zu dürfen brauchst du Root-Rechte.
-
Hallo Kampi,
Wie führe ich das Programm als root aus? Ich starte SPE von der grafischen Oberläche und klicke dann aud "Run"
Ich gebe in der Console sudo python program.py ein und erhalte:
Traceback (most recent call last):
File "python001.py", line 4, in <module>
GPIO.setup(26, GPIO.OUT)
RPi.GPIO.ModeNotSetException: Please set mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
-
Ich mache sowas immer mittels Konsole.
Du meldest dich als Root an und wechselst in den Ordner wo dein Pythonfile liegt.
Anschließend tippst du "python Programmname" ein. Dann führt er das Programm aus.
Edit:
Zeig mal dein Programm bitte.
-
ch gebe in der Console sudo python program.py ein und erhalte:
Traceback (most recent call last):
File "python001.py", line 4, in <module>
GPIO.setup(26, GPIO.OUT)
RPi.GPIO.ModeNotSetException: Please set mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Hier mein kleines Programm:
Code:
import RPi.GPIO as GPIO
import time
GPIO.setup(26, GPIO.OUT)
while True:
GPIO.output(26, True)
time.sleep(1)
GPIO.output(26, False)
time.sleep(1)
-
Hey,
also bei mir klappt es.
Hast du auch RPi.GPIO installiert?
$ wget http://pypi.python.org/packages/sour...O-0.1.0.tar.gz
$ tar zxf RPi.GPIO-0.1.0.tar.gz
$ cd RPi.GPIO-0.1.0
$ sudo python setup.py install
-
ja, hab ich. RPi.GPIO-0.4.1a.tar.gz
-
Hast du es auch installiert (sprich die anderen drei Schritte ausgeführt)? Weil das ist nur das Verzeichnis.
Also bei mir läuft dein Programm problemlos (sowohl direkt in der Konsole als auch als LED.py)
-
Jetzt habe ich alle Programme und die Lib nochmals neu installiert und kann den Code trotzdem nicht kompilieren.
Traceback (most recent call last):
File "python001.py", line 4, in <module>
GPIO.setup(26, GPIO.OUT)
RPi.GPIO.ModeNotSetException: Please set mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)
Professor Google kann mir auch nicht weiterhelfen :-(
So'n sch... aber auch.
-
mmh dann fällt mir auch nichts mehr ein....
Edit:
Schau dir mal das hier an:
http://openmicros.org/index.php/arti...pio-and-python