Python Forum
Please Help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Please Help (/thread-13740.html)

Pages: 1 2


Please Help - ydg - Oct-29-2018

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.


RE: Please Help - wavic - Oct-30-2018

Try to write just python app.py. Without the $.


RE: Please Help - ydg - Oct-30-2018

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


RE: Please Help - wavic - Oct-30-2018

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.


RE: Please Help - ydg - Oct-30-2018

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 ?


RE: Please Help - wavic - Oct-30-2018

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.


RE: Please Help - ydg - Oct-31-2018

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.


RE: Please Help - buran - Oct-31-2018

Check this tutorial https://python-forum.io/Thread-Basic-Set-Windows-Python-Path-to-run-python-in-any-directory

It looks like the way you try to run your script is not correct one.


RE: Please Help - relaximfine - Sep-26-2021

(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


RE: Please Help - relaximfine - Sep-26-2021

(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