Invalid syntax error python

I am using Mbed Studio Version 1.1.0 in windows. I am trying to build the following program.
Mbed os example wakaama

I get the following error

mbed-os-example-wakaama/mbed-os/tools/make.py", line 185
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
^
SyntaxError: invalid syntax

I think this is caused by python version
I have installed python 2.7 in my machine but still inside the mbed studio cli python version is 3.7.1.
What is the solution for this.

Hi Hasitha,

Mbed Studio is distributed with its own version of Python (3.7.1 in release 1.1). It doesn’t use Python installed on your system. Issue exists because the program you are using is using old version of Mbed OS (version 5.4.4). Python tools in that version of Mbed OS are not working correctly with Python 3.
Mbed Studio supports only Mbed OS version 5.12.0 or higher. I recommend if possible updating the Mbed OS version in your program.

Thanks,
Arek - Studio team

Hi Arek,
Do I have to do it manually? Is there a guide or a tool for this.

Thanks.
Hasitha

I think its because in Python 3, print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement. But if you write this in a program and someone using Python 2.x tries to run it, they will get an error. To avoid this, it is a good practice to import print function:

from __future__ import print_function

Now your code works on both python2 and python3