Python Forum
How can I make a python script create an EXE?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I make a python script create an EXE?
#6
(Aug-21-2018, 02:19 PM)ahmed_mokhles Wrote: Well yes I can do that but what I really want is the python code that can produce an EXE, if that is actually possible.
Well that what't Pynstaller dos it create a stand alone .exe file.
Py2exe is not updated anymore(only up to Python 3.4),so don't use it.
# coin_toss.py
import random
import time

class Coin:
    def __init__(self):
        self.sideup = "Heads"

    def toss(self):
        if random.randrange(2) == 0:
            self.sideup = "Heads"
        else:
            self.sideup = "Tails"

def toss_result():
    my_coin = Coin()
    print(f"This side is up: {my_coin.sideup}")
    print("I am tossing the coin...")
    time.sleep(4)
    my_coin.toss()
    print(f"This side is up: {my_coin.sideup}")
    input('Press Enter to exit')

if __name__ == "__main__":
    toss_result()
# Make from command line cmd(i use cmder)
(coin_env) E:\div_code\flatten\coin_env
λ pyinstaller --onefile coin_toss.py

# cd into dist
(coin_env) E:\div_code\flatten\coin_env
λ cd dist

# One stand alone exe file in dist folder
(coin_env) E:\div_code\flatten\coin_env\dist
λ ls
coin_toss.exe*

# Test
(coin_env) E:\div_code\flatten\coin_env\dist
λ coin_toss.exe
This side is up: Heads
I am tossing the coin...
This side is up: Heads
Press Enter to exit
Reply


Messages In This Thread
RE: How can I make a python script create an EXE? - by snippsat - Aug-21-2018, 03:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Make entire script run again every 45 mo NDillard 0 356 Jan-23-2024, 09:40 PM
Last Post: NDillard
  Trying to make a board with turtle, nothing happens when running script Quascia 3 750 Nov-01-2023, 03:11 PM
Last Post: deanhystad
  Is there a *.bat DOS batch script to *.py Python Script converter? pstein 3 3,456 Jun-29-2023, 11:57 AM
Last Post: gologica
  Make console show after script was built with Pyinstaller --NOCONSOLE? H84Gabor 0 1,243 May-05-2022, 12:32 PM
Last Post: H84Gabor
  Make my py script work only on 1 compter tomtom 14 3,998 Feb-20-2022, 06:19 PM
Last Post: DPaul
  How to create a Kibana Visualisation with python script? adzadz 0 1,295 Jul-20-2020, 06:41 AM
Last Post: adzadz
  How to kill a bash script running as root from a python script? jc_lafleur 4 6,010 Jun-26-2020, 10:50 PM
Last Post: jc_lafleur
  How to make this function general to create binary numbers? (many nested for loops) dospina 4 4,525 Jun-24-2020, 04:05 AM
Last Post: deanhystad
  Make the script read from any directory falahfakhri 2 2,223 Jun-15-2020, 02:18 PM
Last Post: falahfakhri
  crontab on RHEL7 not calling python script wrapped in shell script benthomson 1 2,350 May-28-2020, 05:27 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

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