Hallo,
ich möchte per Autostart mit bashrc ein Python Skript ausführen. Dieses soll einen LED Streifen sowie einen Magic Mirror ansteuern. Habe in meiner home/pi/.bashrc datei folgendes hinzugefügt:
Nach dem reboot steht in der Console:
Python
Traceback (most recent call last):
File "/home/pi/Desktop/Autostart.py", line 7, in <module>
from rpi_ws281x import *
ImportError: No module named rpi_ws281x
Wenn ich jetzt aber den Code so ausführe, also mit sudo python3 Autostart.py im Desktop Ordner, funktioniert es ohne Probleme.
Hiernoch der Anfang meines Codes:
Python
#!/usr/local/bin/python
import RPi.GPIO as GPIO
import time
import os
import datetime
import time
from rpi_ws281x import *
import argparse
# Importieren der System-Schnittstelle
# -----------------------------------------------------------------------------
# Initialisierungen
# -----------------------------------------------------------------------------
# --- ToF-Sensor initialisieren -----------------------------------------------
GPIO_PIR = 27
GPIO.setmode(GPIO.BCM)
GPIO.setup(GPIO_PIR, GPIO.IN)
# --- Funtionen zum Einschalten des Bildschirms via HDMI ----------------------
def bildschirm_ein():
os.popen('vcgencmd display_power 1')
# --- Funtionen zum Ausschalten des Bildschirms via HDMI ----------------------
def bildschirm_aus():
os.popen('vcgencmd display_power 0')
# --- Variablern initialisieren -----------------------------------------------
personDetect = 0 # noch keine Person detektiert
distanceThreshold = 1000.0 # Abstandsschwellwert in [mm]
screenOnTime = 60.0 # Zeit in [s], wie lange das Display mindestens
# eingeschaltet bleiben soll
measurementInterval = 1.0 # Messintervall in [s]
bildschirm_aus() # Relais/Bildschirm wird ausgeschaltet
# -----------------------------------------------------------------------------
# Eigentliches Programm in Endlosschleife
# -----------------------------------------------------------------------------
Current_State = 0
Previous_State = 0
# LED strip configuration:
LED_COUNT = 225 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
#Verschiedene Modi
def Farben(strip, color, wait_ms=2):
# """Wipe color across display a pixel at a time."""
for i in range(strip.numPixels()):
strip.setPixelColor(i, color)
strip.show()
time.sleep(wait_ms/10000)
Alles anzeigen
Habe auch schon probiert das Modul in einen Test Ordner zu installieren und das Script in den selben Ordner geschmissen. Was mache ich falsch?