Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Please Help
#1
I am trying my first program on python, the common "hello world".
I am using visual studio and I wrote print("hello world").
I wrote
$python app.py
in the terminal, and this is the answer I get
At line:1 char:9
+ $python app.py
+ ~~~~~~
Unexpected token 'app.py' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken


This should be a very simple operation, yet, I am not sure what is happening.
Any help would be appreciate.
Thank you very much.
Reply
#2
Try to write just python app.py. Without the $.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#3
Just tried, and unfortunately this is what I get:

python : The term 'python' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ python app.py
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (python:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Reply
#4
Hm! Windows? I think you have to use the full path to the Python executable. I'm not sure if you can make a shortcut to that file in c:\Windows.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
Yes,
I recently updated my Windows with the latest version,
however, I am not sure I am understanding what you really mean
when you say: "use the full path to the Python executable" nor "make a shortcut to that file in c:\Windows".
In short, what should I do exactly step by step ?
Reply
#6
Let's say Python is installed in c:\Windows\Program files\Python37\. So you can run the script like this:
c:\Windows\Program files\Python37\python app.py
About the shortcut... I don't remember how one could be made in Windows. But this is a single name/file which points to c:\Windows\Program files\Python37\python directly. For instance.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
Thanks for your reply.
And as you guessed, there is no way as far as I know to make that kind of shortcut.
Now the problem still remains, do you perhaps know if there is another way for me to
solve this issue? It must be, but I haven't managed to figure out what to do.
Reply
#8
Check this tutorial https://python-forum.io/Thread-Basic-Set...-directory

It looks like the way you try to run your script is not correct one.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#9
(Oct-29-2018, 09:54 PM)ydg Wrote: I am trying my first program on python, the common "hello world".
I am using visual studio and I wrote print("hello world").
I wrote
$python app.py
in the terminal, and this is the answer I get
At line:1 char:9
+ $python app.py
+ ~~~~~~
Unexpected token 'app.py' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken


This should be a very simple operation, yet, I am not sure what is happening.
Any help would be appreciate.
Thank you very much.

man thank you so much, i just started learning and damn it took me a day to find this answer hahahaha i am so happy it now worked
Reply
#10
(Oct-30-2018, 04:36 AM)wavic Wrote: Try to write just python app.py. Without the $.

Thank you so much man, I just started learning python and it took me a day to find this answer! I am so happy it worked now
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020