0

Python Running Programme

Hi all, I'm new to python, I've installed python 3.8 and works in command prompt. I've written my first programme called test.py which simply prints "hello world!" to the screen. However, when I type in python3 test.py into python, it prints: File "<stdin>", line 1 python3 test.py ^ SyntaxError: invalid syntax I have tried to set the environmental variables so that it reads it from right place but not 100% sure this is correct. Any help will be appreciated!

17th Mar 2021, 8:17 PM
Luke
Luke - avatar
4 Respuestas
+ 1
'python' is an executable wich should be run in terminal, not in python command line...
17th Mar 2021, 8:26 PM
visph
visph - avatar
0
Thanks! Just tried and it works, what is the purpose of having python terminal if python programmes can be run from the terminal?
17th Mar 2021, 8:30 PM
Luke
Luke - avatar
0
python command line is used to run python commands line by line... notice that to run python command line you run 'python' in terminal, and to run a python script, you run 'python filename.py' in terminal also ;)
17th Mar 2021, 8:32 PM
visph
visph - avatar
0
(python or python3 or anything else: it mostly depends on wich versions are installed in your system ^^)
17th Mar 2021, 8:33 PM
visph
visph - avatar