Python Forum
.py to exe or to executable file for linux
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.py to exe or to executable file for linux
#1
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
Reply
#2
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).
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply
#3
(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?
Reply
#4
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
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#5
(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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  create exe file for linux? korenron 2 976 Mar-22-2023, 01:42 PM
Last Post: korenron
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,328 May-24-2022, 07:02 AM
Last Post: netanelst
  problem with pyinstaller to create an executable file atlass218 0 2,570 May-15-2021, 11:01 AM
Last Post: atlass218
  Want to take a Screenshot from a File in Linux dhiliptcs 2 2,561 Oct-21-2019, 01:22 PM
Last Post: dhiliptcs
  Run .py file in Kali Linux Terminal grayarea3 4 28,601 Feb-27-2019, 06:51 PM
Last Post: buran
  how to compile a stand alone executable on linux? JackDinn 4 7,075 Mar-11-2018, 10:22 PM
Last Post: JackDinn
  Print the file using the associated application on Linux Borisko 1 3,667 Oct-15-2017, 07:14 AM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020