Python - EOF error on input only in Linux terminal

560 Views Asked by At

It is working in VS CODE terminal but not in linux terminal.ERROR:

File "/home/shaheer/start.py", line 10, in <module>
ques = input("Are you ready? (y/n)")
EOFError: EOF when reading a line

MY CODE:

import os
import subprocess
from subprocess import Popen, PIPE, STDOUT
from subprocess import DEVNULL
import webbrowser
import time

time.sleep(10)

ques = input("Are you ready? (y/n)")
if ques == "y":
  print("Good!")
elif ques == "Y":
  print("Good!")
else:
  cmd = "pkill chrome"
  Popen([cmd], stderr=subprocess.DEVNULL, stdin=PIPE, shell=True)

I am making it as a reminder script for people who use their system for a long time.

1

There are 1 best solutions below

0
On BEST ANSWER

[UPDATE] it's now working, i had to make another .py file and link that to this one. file 1 (start.py):

import os
os.system("python3 /home/shaheer/playsound.py")

file 2 (playsound.py):

import os
import subprocess
from subprocess import Popen, PIPE, STDOUT
from subprocess import DEVNULL
import webbrowser
import time

time.sleep(10)

ques = input("Are you ready? (y/n)")
if ques == "y":
  print("Good!")
elif ques == "Y":
  print("Good!")
else:
  cmd = "pkill chrome"
  Popen([cmd], stderr=subprocess.DEVNULL, stdin=PIPE, shell=True)