【问题标题】:raspbian python script EOF error at startup启动时 raspbian python 脚本 EOF 错误
【发布时间】:2017-10-25 09:22:04
【问题描述】:

我正在尝试设置一个非常简单的脚本来处理通过 vlc 在树莓派 3 模型 B 上播放培训视频。

我可以启动到 CLI 并正常运行程序,但是如果我将它添加到 rc.local,我会在第 60 行收到错误,EOFError: EOF when reading a line 谁能帮我解决这个问题?

第 60 行是"entry = input("\nVideo to play: ")",在这段摘录的底部,除此之外,代码几乎相同。

import os,subprocess
entry = " "           #variable to hold input on the main menu
entry2 = " "          #variable to hold input on the VERVE menu
looping = False       #variable that decides if videos should loop
lastinput = " "       #variable holds last input on the main menu

while entry != "0":

    if entry == "1":
        lastinput = "Camco Chemical Safety Training"
    elif entry =="2":
        lastinput = "[ENG] Forklift Operator Safety Training"
    elif entry =="3":
        lastinput = "[ESP] Forklift Operator Safety Training"
    elif entry =="4":
        lastinput = "[ENG] The New Hazard Communication Mandate"
    elif entry =="5":
        lastinput = "[ESP] The New Hazard Communication Mandate"
    elif entry =="6":
        lastinput = "Forklift Training (1 of 2)"
    elif entry =="7":
        lastinput = "Forklift Training - Accidents (2 of 2)"

        #open main menu
    os.system("printf '\033c'") #These lines are what wipe out the text from the last screen
    if looping == True:
        print("VIDEOS ARE CURRENTLY LOOPING")
    print("Last video watched: " + lastinput)
    print("\n1. Camco Chemical Safety Training")
    print("2. [ENG] Forklift Operator Safety Training")
    print("3. [ESP] Forklift Operator Safety Training")
    print("4. [ENG] The New Hazard Communication Mandate")
    print("5. [ESP] The New Hazard Communication Mandate")
    print("6. Forklift Training (1 of 2)")
    print("7. Forklift Training - Accidents (2 of 2)")
    print("8. VERST DHL")

    print("\n9. TOGGLE VIDEO LOOP")
    print("0. Close Program")

    print("\nPress 0 at any time during a video to close it.")

    entry = input("\nVideo to play: ")
    if entry == "1":
        #open Camco Chemical Safety Training - if looping is off, play once, if it's on, play forever.
        if looping == False:
            subprocess.call(['vlc', "/home/pi/Desktop/Training/Camco_Training/Camco.mp4", '-Idummy --play-and-exit'])
        elif looping == True:
            subprocess.call(['vlc', "/home/pi/Desktop/Training/Camco_Training/Camco.mp4", '-Idummy --loop'])
        continue

【问题讨论】:

  • 该错误似乎与python脚本无关,而是与rc.local有关,请检查那里的语法。

标签: python linux


【解决方案1】:

Pedro 是对的,我可以通过更改加载方式让它运行。现在我把它从 rc.local 中删除并添加到 .bashrc 中运行得很好

启动 rpi 到 cli

sudo nano /home/pi/.bashrc

最后一行

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

【讨论】:

    猜你喜欢
    • 2015-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多