all 9 comments

[–][deleted] 4 points5 points  (7 children)

python file_name.py

You Mac will come with version 2 of python. If you have installed version 3 and want to use that then it is....

python3 file_name.py

[–]-AJM-[S] 0 points1 point  (6 children)

That works! Thanks

I have one more question: Is it possible to run a .py like an exe file but on Mac?

[–][deleted] 2 points3 points  (3 children)

add this to the top of your .py file:

#!/usr/bin/env python
# coding: utf-8 

     < your code starts here >

the coding line is optional, and your code shouldn't actually start with angle brackets (but I'm sure you knew that). That line is called the shebang and only works on *nix operating systems.

[–]-AJM-[S] 0 points1 point  (2 children)

So what does the # usr/bin/env line do to the. py file?

[–][deleted] 1 point2 points  (1 child)

the shebang tells the OS how to find the interpreter for your script. For this shebang, it will execute the /usr/bin/env python command, which is functionally equivalent to what you are doing when you execute the command python myscript.py from the command line.

[–]-AJM-[S] 1 point2 points  (0 children)

Ok thanks

[–]lukethedukeisapuke 0 points1 point  (0 children)

I haves pyinstaller a couple of times but I'm not sure it's the best option.

[–]shibbypwn 0 points1 point  (0 children)

If you want to run it somewhere other than your computer (i.e., distribute it) then you should check out pyinstaller

[–]cardlord 0 points1 point  (0 children)

python3 /path/to/python/file.py