Python Forum

Full Version: .py to exe or to executable file for linux
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How would you convert a .py file to a .exe for distribution to a windows machine and also how would I make a version of an executable file on linux that could just be double clicked on or ran in the terminal by typing the file name like you would pycharm or dia or anything of that nature. I usually run the .py program in IDLE or in pycharm but I'd like to write code for other machines to be able to use as ease of access by just clicking on the program file
For Linux you just make sure the first line of the file contains #!/usr/bin/env python2 or #!/usr/bin/env python3 and that the file has the executable bit set (you can also drop the .pyextension).
(Apr-23-2017, 12:10 AM)Ofnuts Wrote: [ -> ]For Linux you just make sure the first line of the file contains #!/usr/bin/env python2 or #!/usr/bin/env python3 and that the file has the executable bit set (you can also drop the .pyextension).

Could you give an example? I still thing im getting it wrong lol. Also what about converting to .exe for windows executable? Ohhh wait nevermind you meant add that in the code... haha ok. Now what about Windows?
To make an .exe file you need a Windows box.

Linux. On top of the script you have to put this line: #!/usr/bin/env python2. Or #!/usr/bin/env python3 for Python 3 respectively.
To set the executable bit: sudo chmod +x script_name.py. Or sudo chmod 550 script_name.py
(Apr-23-2017, 03:52 AM)wavic Wrote: [ -> ]To make an .exe file you need a Windows box.

Linux. On top of the script you have to put this line: #!/usr/bin/env python2. Or #!/usr/bin/env python3 for Python 3 respectively.
To set the executable bit: sudo chmod +x script_name.py. Or sudo chmod 550 script_name.py

Thanks wavic. I'll look up the info on windows box