1

I am very new to python and I am trying to execute a python file called HelloWorld.Py. The code within the file editor is

#! Python3 print('Hello world!') 

I am trying to do this from my windows command line. The correct path from what I can tell in my documents application is C:\Users\china\PythonFiles\HelloWorld.py.

As I am following a Udemy course, it is recommended that you type py.exe C:/Users/china/PythonFiles/HelloWorld.py (filled in with my example).

At first, I returned a syntax error for the use of py.exe. Reading online made me confused about what to put in front of C:, and after removing py.exe, and just typing C:/Users/china/PythonFiles/HelloWorld.py returns the error 'Unable to create process using 'Python3 "C:\Users\china\PythonFiles\HelloWorld.py" '

What am I doing wrong? I have researched online for a few hours and I am still no closer to figuring it out. Please help!

2
  • Please add your HelloWorld.py file (edit your question), so I can take a look at the code. Seems like there might be a problem with your script. Commented Nov 20, 2020 at 18:13
  • Fixed to include code I wrote in the file. Thank you Commented Nov 20, 2020 at 18:17

1 Answer 1

1

Remove the comment, or change it to #!python3. py.exe doesn't like the capitalization.

The comment isn't needed unless you have both Python 2 and Python 3 installed, and it hints to py.exe which Python to use, but requires lowercase python followed by the major and optionally minor version, e.g #!python3.6 or #!python3. If the comment is missing, the latest version of Python installed wiil be used.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.