Reputation:
I am a learner of python.
i created one simple python script named as test.py file location(/Users/AnbeswaranK/Desktop/python/test.py.
when i try to run the the script i am getting below error.
>>> python test.py
SyntaxError: invalid syntax
>>>
>>> python /Users/AnbeswaranK/Desktop/python/test.py
SyntaxError: invalid syntax
>>>
I have tried with location url and without but unable to run.
can any one help me to understand, what i have to do
Thanks in advance
Upvotes: 0
Views: 7899
Reputation: 1
Based on what I am seeing, primarily with ">>>python test.py" this tells me that the reason why you have an error is because you wrote it in the IDLE Shell and saved it. I just ran into this problem and figured it out.
So what you are going to want to do is this:
Upvotes: 0
Reputation: 1
Check test.py and make sure you have only python command. I had the same as I saved from IDLE with all not necessary text coming by default with IDLE. I.e.:
print('Hallo')
cd /Users/AnbeswaranK/Desktop
python test.py
When you want to create a new python file just click on "File-->New File" of the IDLE :-)
Let me know if this works
Upvotes: 0
Reputation:
Open your command prompt.
Navigate to the folder where your test.py is located.
type and enter: python test.py
Upvotes: 0