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)
4
  • 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. Commented Feb 1, 2016 at 16:42
  • 1
    Are you sure you're not inadvertently using python 2.x? Commented Feb 1, 2016 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 "<string>", line 1 roll 10 SyntaxError: unexpected EOF while parsing Commented Feb 1, 2016 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. Commented Feb 1, 2016 at 17:58

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.