启动时出现 EOFerror

EOFerror on startup

启动时加载脚本后出现错误 EOFerror: 脚本在 CLI 模式下为 运行。 读取一行时出现 EOF。

Barcode: Trace back (most recent call last): File "/home/pi/BCKHL.py", line 48, in compare() File "/home/pi/BCKHL.py", line 20, in compare barcode=input("barcode:")

手动 运行 时脚本正在运行。

这是脚本代码:

import RPi.GPIO as GPIO
    ###setup###
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(18, GPIO.OUT) #Ventil 1#
GPIO.output(18, GPIO.LOW)
GPIO.setup(21, GPIO.OUT) #Ventil 2#
GPIO.output(21, GPIO.LOW)
GPIO.setup(38, GPIO.OUT) #Ventil 1 crvena led#
GPIO.output(38, GPIO.HIGH)
GPIO.setup(40, GPIO.OUT) #Ventil 1 zelena led#
GPIO.output(40, GPIO.LOW)
GPIO.setup(35, GPIO.OUT) #Ventil 2 crvenaled#
GPIO.output(35, GPIO.HIGH)
GPIO.setup(37, GPIO.OUT) #Ventil 2 zelena led lampa#
GPIO.output(37, GPIO.LOW)

def compare():
    while True:
        barcode=input("Barcode:")
        if barcode=="S5000070931":
            GPIO.output(18, GPIO.HIGH)            
            GPIO.output(21, GPIO.LOW)
            GPIO.output(38, GPIO.LOW)
            GPIO.output(40, GPIO.HIGH)
            GPIO.output(35, GPIO.HIGH)
            GPIO.output(37, GPIO.LOW)

            continue
        elif barcode=="S5000057670":
            GPIO.output(18, GPIO.LOW)
            GPIO.output(21, GPIO.HIGH)
            GPIO.output(40, GPIO.LOW)
            GPIO.output(38, GPIO.HIGH)
            GPIO.output(35, GPIO.LOW)
            GPIO.output(37, GPIO.HIGH)
            continue
        else:
            print("Molim Vas da skenirate ispravan barkod")
            GPIO.output(18, GPIO.LOW)
            GPIO.output(21, GPIO.LOW)
            GPIO.output(38, GPIO.HIGH)
            GPIO.output(35, GPIO.HIGH)
            GPIO.output(40, GPIO.LOW)
            GPIO.output(37, GPIO.LOW)
            continue

compare()

有谁知道如何解决这个问题?

谢谢。

尝试 运行 来自 .bashrc

sudo nano /home/pi/.bashrc

在最后一行写:

echo Running at boot 
sudo python3 /home/pi/BCKHL.py

如果你还有它,请不要忘记将它从 rc.local 中删除。