启动时的EOFerror

问题描述 投票:0回答:1

在启动时加载脚本后我收到错误EOFerror:脚本在CLI模式下运行。读取线时的EOF。

条形码:追溯(最近一次调用最后一次):文件“/home/pi/BCKHL.py”,第48行,在compare()文件“/home/pi/BCKHL.py”,第20行,比较条形码=输入(“条码:”)

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

这是脚本的代码:

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()

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

谢谢。

python startup eof eoferror
1个回答
0
投票

尝试从.bashrc运行它

sudo nano /home/pi/.bashrc

在最后一行写道:

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

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

© www.soinside.com 2019 - 2024. All rights reserved.