Andrew Liu
Andrew Liu

Reputation: 88

EOFError: EOF when reading a line, can't figure out why

I've been trying to make a python Among Us game (kinda I guess) but this error has been really annoying. Here is my code:

import random
print("Python Among Us")
print()
role = ["Crewmate", "Crewmate" , "Crewmate", "Crewmate", "Crewmate", "Crewmate", "Crewmate", "Crewmate", "Crewmate", "Impostor"]
roleconfirmed = random.choice(role)
print("You are a", roleconfirmed, "!")
if roleconfirmed == ("Crewmate"):
    firstdestination = input("Where would you like to go? ")

Here is the exact error in the console:

Python Among Us

You are a Crewmate !
Where would you like to go? Traceback (most recent call last):
  File "main.py", line 8, in <module>
    firstdestination = input("Where would you like to go? ")
EOFError: EOF when reading a line

Any ideas why this error still persists?

Upvotes: 0

Views: 5414

Answers (1)

v_ns
v_ns

Reputation: 83

I think you are using an online IDE, or giving an empty input file to read input from.

I was able to re-generate your exception, when i created an empty file empty.txt and passed that as argument while running above code segment.

$ python3 main.py < empty.txt
Python Among Us

You are a Crewmate !
Where would you like to go? Traceback (most recent call last):
  File "/Users/vishvanath/Desktop/test/main.py", line 8, in <module>
    firstdestination = input("Where would you like to go? ")
EOFError: EOF when reading a line

Here, main.py contains code segment provided in question and empty.txt is just an empty file.

So error occurs, because your program is expecting an input, but there is none.

Upvotes: 1

Related Questions