0

I installed the PyCharm and python on my computer and trying to write this simple piece of code but I get error.

for i in range(10):
  x = 0.1*i
  print( x )
  print( x / ( 1 - x * x ) )

The error is:

File "C:/WinPython-2.7.6.2-64/python-2.7.6.amd64/Lib/site-    
packages/ib/opt/wrapper_v5.py", line 50
    print errormsg
             ^
SyntaxError: Missing parentheses in call to 'print'

Process finished with exit code 1

Do I need any header statements like in C++. I am coming from C++ and Matlab background.

Zanam
  • 4,607
  • 13
  • 67
  • 143
  • 2
    This...this is a library-level error. Are you explicitly running this code under Python 2? – Makoto Dec 10 '15 at 21:51
  • Please elaborate as I don't understand your comment. This was my first python code. – Zanam Dec 10 '15 at 21:52
  • The error you're getting *isn't* directly caused from your code. How did you install Python, and how are you invoking it from PyCharm? – Makoto Dec 10 '15 at 21:52
  • I use the run option from the IDE of Pycharm. I am going to reinstall everything and see if that makes a difference. – Zanam Dec 10 '15 at 21:55
  • probable duplicate of : http://stackoverflow.com/questions/25445439/what-does-syntaxerror-missing-parentheses-in-call-to-print-mean-in-python/ – user 12321 Dec 10 '15 at 21:57
  • Possibly it will be useful to setup interpreter in **pycharm**: File -> Settings -> Project -> Project interpreter. Seems that it should be python3 branch for your code. – avtomaton Dec 10 '15 at 22:08

1 Answers1

-4

You use this:

for i in range(10):
   x = 0.1*i
   print( x )
   print( x / ( 1 - x * x ) )

but in Python 2 it's:

for i in range(10):
    x = 0.1*i
    print x 
    print x / ( 1 - x * x )

Your piece of code is written in Pyhton3 so maybe install that or learn python2 in a different tutorial or something.

  • Wow didn't realize that much would be difference between versions .. thanks – Zanam Dec 10 '15 at 21:57
  • Yeah it's not that big really but for the standard stuff like print and unicode it is. – B. ten Lohuis Dec 10 '15 at 21:58
  • 5
    This is unlikely to solve the OP's problem. 1) The error happens in `wrapper_v5.py`, not in his code. 2) The Py3 syntax (`print()` as a function, with parenthesis) works just fine for Py2. – Lukas Graf Dec 10 '15 at 21:58