Raspberry PI und GPIOs unter Python läuft nicht

OP #2840904
Lesenswert?

Guten Abend Zusammen,
wie der Betreff es schon erahnen lässt beomme ich die GPIOs unter Python 
nicht zum laufen. Weder mit python 2 noch 3.2 und da obwohl ich die 
"RPi.GPIO-0.3.1a" installiert habe.

Programm:
1
import RPi.GPIO as GPIO
2

3
# Set up the GPIO channels - one input and one output
4
GPIO.setup(25, GPIO.OUT)
5

6
# Output to pin 25
7
# GPIO.output(25, True)
8

9
while True:
10
  GPIO.output(25, True)
11
  print("on")
12
  time.sleep(.2)
13
  GPIO.output(25, False)
14
  print("off")
15
  time.sleep(.2)
Fehlermeldung:
1
pi@raspberrypi ~ $ sudo python3.2 /home/pi/pytests/led_out.py
2
Traceback (most recent call last):
3
  File "/home/pi/pytests/led_out.py", line 1, in <module>
4
    import RPi.GPIO as GPIO
5
ImportError: No module named RPi.GPIO
6
pi@raspberrypi ~ $
"sudo apt-get update" hat auch nichts gebracht

Hat jemand einen Rat für mich?

Dank und Gruß Philipp
OP #2842564
Lesenswert?

Hallo Zusammen,
erst mal danke für eure Unterstützung. Ich habe es unzählige male 
versucht. Der Ausschlaggebene Unterschied (so vermute ich) war das ich 
das entpacken des tar Achivs auf dem PI anstat mit WinRar unter Windows 
gemacht habe.
Evtl. war es auch das ich die Installation/ausführung der Anwendung mit 
Python3.2 versucht habe.
Folgende Reinfolge führte bei mir nun zum Erfolg
1
pi@raspberrypi ~ $ sudo apt-get update
2
pi@raspberrypi ~ $ sudo apt-get install python3-dev
3
pi@raspberrypi ~ $ cd /home/pi/
4
pi@raspberrypi ~ $ tar -xvf RPi.GPIO-0.3.1a
5
pi@raspberrypi ~ $ cd RPi.GPIO-0.3.1a
6
pi@raspberrypi ~/RPi.GPIO-0.3.1a $ sudo python3 setup.py install

Dann läuft auf folgende "mini" Anwendung.
1
import RPi.GPIO as GPIO
2

3
# to use Raspberry Pi board pin numbers
4
GPIO.setmode(GPIO.BOARD)
5

6
# set up GPIO output channel
7
GPIO.setup(12, GPIO.OUT)
8

9
# set RPi board pin 12 high
10
GPIO.output(12, GPIO.HIGH)
11

12
# set up GPIO input with pull-up control
13
#   (pull_up_down be PUD_OFF, PUD_UP or PUD_DOWN, default PUD_OFF)
14
GPIO.setup(11, GPIO.IN, pull_up_down=GPIO.PUD_UP)
15

16
# input from RPi board pin 11
17
input_value = GPIO.input(11)
18

19
# to change to BCM GPIO numbering
20
GPIO.setmode(GPIO.BCM)

Ich hoffe das hilft irgendwan auch mal anderen ;-)

Gruß Philipp

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren