python version conflict with json.dumps

13,020

Python 3.x changed print statement to be print functions

Python 2.x:

print "Hello World" 

Python 3.x

print("Hello World")

So because you are running on python 3.x you will need to update your code to use the 3.x print style (e.g., print function calls).

print( json.dumps(evaluate(), indent=4) )
Share:
13,020
epsilones
Author by

epsilones

Updated on June 08, 2022

Comments

  • epsilones
    epsilones over 1 year

    I am a newb to python. I am running a script I got on the web :

    python file.py
    

    I get this :

    File "file.py", line 293
        print json.dumps(evaluate(), indent=4)
                 ^
    SyntaxError: invalid syntax
    

    I read it is related to python version, that should be some 2.7. So I downloaded pyenv. And I set the right version in the directory that contains file.py : pyenv local 2.7.10. But I still get the same error.

    (For information, I am trying to install blockchain tool : ethereum)

  • tdelaney
    tdelaney almost 8 years
    There are other differences between 2 and 3 besides just print. Converting may be a major lift.