0

I'm facing a weird issue here. My program fetches user id during execution via input command. When I test the code through eclipse development suite, it works perfectly. But when I invoke the python code through a windows bat file, it errors out. Output from console with error message is listed below.

 *Enter User id :- test@gmail.com

Traceback (most recent call last):
  File "C:\Users\Workspace\Py\MISC\test.py", line 118, in <module>
    main(inifile)
  File "C:\Users\Workspace\Py\MISC\test.py", line 54, in main
    user_id = str(input("Enter User id for BI portal :- "))
  File "<string>", line 1
    test@gmail.com
        ^
SyntaxError: invalid syntax
C:\Users\Workspace\Py\MISC>pause
Press any key to continue . . .*               

I have also noticed that if I provide input as "test@gmail.com" it works fine in windows console..

Contents of my bat file pasted below.

REN @echo off
python "C:\Users\Workspace\Py\MISC\test.py" config.ini%
pause
Wally
  • 3
  • 3
  • 1
    It is failing when you try and run it in Python 2. In that `input` tries to evaluate whatever the user types, and you need to use `raw_input` instead. – khelwood Mar 23 '18 at 15:41
  • No its not Python 2, my version is 3.5. It works if I provide input as "test@gmail.com", (including quotes). I don't want user to do that :-) – Wally Mar 23 '18 at 15:43
  • 2
    You might not have realised you were running Python 2, but you are. What you are describing is exactly what happens in Python 2. – khelwood Mar 23 '18 at 15:43
  • My bad.. I checked the python version from cmd prompt and I have python 2.7 too... So my eclipse was using python 3 and cmd prompt picked up the 2.7 version... Thanks a lot.. – Wally Mar 23 '18 at 15:47

0 Answers0