0

I'm writing a console application in python 3, and when I run my code in the Pycharm IDE, it runs just fine. If I run the code by opening it in python3, I get the exception "unexpected EOF while parsing (, line 1)" from the input statement.

I figure Pycharm is doing something for me to make this work, but I don't have any idea what it is. Here's the section of code where the error occurs. I'm calling this from a main method in another module that constructs some objects with commands in them to reference in the console. import appExceptions

def runConsole(commands, packages, commandLog):
    while(True):
        try:
            print("DEBUG - getInput")
            userInput = input("> ").split()
            print("DEBUG - inputGotten")
            commandLog.append(userInput)
            if len(userInput) == 0:
                continue
            executeInput(commands, packages, userInput)
        except appExceptions.UnknownCommandException as e:
            print(e.msg)
        except appExceptions.IncorrectArgumentsException as e:
            print(e.msg)
icaughtfireonce
  • 171
  • 1
  • 10
  • 1
    Con you explain how you are running this? Exactly what does "opening it in python3" mean? Could you also show the whole of the traceback please? That exception message is usually preceded by an error, like `SyntaxError`. – cdarke Feb 01 '16 at 16:42
  • 1
    Are you sure you're not inadvertently using python 2.x? – machine yearning Feb 01 '16 at 16:43
  • Traceback: File "appRunner.ph", line 22, in main console.runConsole(commands, packages, commandLog) File line 14, in runConsole userInput = input("> ").split() File "", line 1 roll 10 SyntaxError: unexpected EOF while parsing – icaughtfireonce Feb 01 '16 at 17:52
  • I had accidentally opened this in python 2, and then deliberately gone into windows to tell it to open with python 3, but it apparently did not like that. and was sill running the program in python2.7 because when I uninstalled python2, the program started working. – icaughtfireonce Feb 01 '16 at 17:58

1 Answers1

1

You get that kind of error if your input is empty string.

>>> input().split()

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing
matejm
  • 270
  • 1
  • 10