gpt4 book ai didi

python - 启动时 raspbian python 脚本 EOF 错误

转载 作者:太空宇宙 更新时间:2023-11-04 12:27:40 25 4
gpt4 key购买 nike

我正在尝试设置一个非常简单的脚本来处理通过 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

最佳答案

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

启动 rpi 到 cli

sudo nano /home/pi/.bashrc

最后一行

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

关于python - 启动时 raspbian python 脚本 EOF 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44168415/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com