-2

Import success however SyntaxError: invalid syntax error even for simple function

I am trying to this library

This is the simplest sample

from yahoo_finance import Share
yahoo = Share('YHOO')
print yahoo.get_open()

shows error like this.

  File "yahoofinancetest.py", line 3
    print yahoo.get_open()
              ^
SyntaxError: invalid syntax

It's too simple to get clue for solving

Where should I check??

whitebear
  • 11,200
  • 24
  • 114
  • 237
  • 3
    Are you in Python3 ? If it's the case, may the problem come from that in Python3, print is a function (and not a keyword like in Python2). So you have to do `print(yahoo.get_open())` – Darkaird Jul 28 '17 at 10:03
  • which python version are you running on? – Gahan Jul 28 '17 at 10:03
  • Thank you very much , I though it is because of library, but python itself, I use python 3.5 – whitebear Jul 28 '17 at 10:31

1 Answers1

0

If python 3, print is a function try:

print(yahoo.get_open())
trex
  • 3,848
  • 4
  • 31
  • 54