In order to run a Python (.py extension) file from the Mac Terminal all you need to do is type python3 followed by the name of the Python file.
Example:- Open Mac Terminal,
- Type,
python3 <file-name>% python3 HelloWorld.py Hello World!

If you are using an older version of Python, then you may have to use python instead of python3
If Python is not installed on your Mac you will get an error,
% python3 HelloWorld.py
zsh: command not found: python3
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!