Text of discuss.python.org › t › cant-get-python-to-run-in-cmd › 20245 as Styx crawled it on Nov 20, 2026. The page may have changed since. Only its words are kept, without pictures or layout.

Open the live page

Can't get python to run in cmd - Python Help - Discussions on Python.org

Can't get python to run in cmd Python Help help CompNoob (Cole) October 24, 2022, 3:28am 1 Hello All, I’m trying to learn some coding skills to help out with my job so I’m going through a course. However, when I try to run the simple print(‘Hello World’) scripted through the cmd I get the following error. I have already tried adding to the path and C:/Windows/system 32/ python --version and get the correct version as the output.

Not sure where to go from here. Input through cmd: C:\(file path)\python hello.py Output: File "C:\(file path)\hello.py", line 1 Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32 ^^^^ SyntaxError: invalid syntax Code hello.py: #Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32 #Type "help", "copyright", "credits" or "license()" for more information. print("Hello World") Screenshot 2022-10-23 232614 869×73 20.5 KB cameron (Cameron Simpson) October 24, 2022, 4:10am 2 I’m trying to learn some coding skills to help out with my job so I’m going through a course.

However, when I try to run the simple print(‘Hello World’) scripted through the cmd I get the following error. […] Screenshot 2022-10-23 232614 869×73 20.5 KB Please just paste the output dirctly into your message between triple backticks, like this: ``` your pasted output goes here ``` Email users (like me) don’t see the screenshots (I just had to visit the forum), we can’t copy/paste from screenshots, and the visually impaired have trouble with screenshots.

That said: I think you’ve pasted in a complete transcript of a Python interactive session into your hello.py Python script. Most of the verbiage is not Python source code, it’s output. Here’s a transcript from my terminal here: [~]fleet2*> python3 Python 3.10.6 (main, Aug 11 2022, 13:47:18) [Clang 12.0.0 (clang-1200.0.32.29)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> print("Hello world!") Hello world! >>> The only stuff I’ve typed is python3 at my shell prompt to start the Python interpreter, and then I typed print("Hello world!") at the >>> interactive Python prompt.

Can you show what’s in your hello.py file? Again, copy/paste directly into the reply message between triple backticks. A typical hello world script might look like this: #!/usr/bin/env python3 print("Hello world!") in its entirely. And the first line is a comment! (Most Python scripts commence with this special “shebang” comment, which makes them work seamlessly on most systems as commands; do not worry about this for now.) Cheers, Cameron Simpson cs@cskk.id.au CompNoob (Cole) October 24, 2022, 5:18pm 3 Thanks Cameron, I have updated my post with the information you’re looking for hopefully. vbrozik (Václav Brožík) October 24, 2022, 9:00pm 4 It looks like you are showing a different file than the file which produced the traceback.

The hash character # does not show in the traceback. Did you change the directory ( cd ) to the directory with the correct hello.py ? Do you have a reason to have the first two lines in your program file? If not, delete them and leave just the actual python code: print("Hello World") cameron (Cameron Simpson) October 24, 2022, 9:26pm 5 Please just post replies for updates. I’m on email and do not visit the web side very much.

So I won’t see your updates until I make the time to go there, and then I probably need to decode them from what your original post used to say. Cheers, Cameron Simpson cs@cskk.id.au cameron (Cameron Simpson) October 24, 2022, 11:46pm 6 I’ve looked at your updated post. Your hello.py shows commented out #Python etc lines, which are fine. But the error message recites a line with no leading comment ( # ) marker. That suggests that the current code in hello.py is not the version of the code which produced the error message.

Cheers, Cameron