Skip to content
← Back to Community
How to create EXE's from Python!
Profile icon
JordanDixon1

EXE's from python??

That's Right EXE's from Python! And it is really simple too! Why would you want to? Because now-a-day's everyone wants to download exe's and run them in order to play games not download python then your source file and run it.

Okay... What's the catch?

There is none. Create your main.py.

print("Hello World!") input("press enter to exit.") # A simple app to print hello world! Use your code instead.

Then run it to be sure it works. If it does now we can build it as an exe. All we have to do is use pip to install pyinstaller

pip install pyinstaller

This will install pyinstaller along with all of it's dependencies. Also note, that pyinstaller only makes an exe based on the os it is on. For example: If I build an exe on windows I can not use it on Mac.
Now once pyinstaller is installed, go to the directory of your main.py file using cmd prompt or bash and use this code:

pyinstaller -F main.py

What this will do is bundle everything into one exe file in a folder called dist. Open the folder once it's done and run the exe and you will get your python code run!

Voters
Profile icon
Nerdzy
Profile icon
s10800732
Profile icon
MichelSil
Profile icon
DavidHinton1
Profile icon
DSAJagat20
Profile icon
Crazyboy119
Profile icon
Lacob1
Profile icon
dantastic
Profile icon
NoelB33
Profile icon
JordanDixon1
Comments
hotnewtop
Profile icon
SethikaKodithuw

After converting to exe, how do you download the file? When I try, repl only saves the python file.

Profile icon
JordanDixon1

@SethikaKodithuw This is true... I don't know why it does this but I will find a work around and tell you as soon as I do.

Profile icon
DSAJagat20

Okay so I did it, and it does nothing. It just creates two folders. are we supposed to download this somehow??

Profile icon
James2008

I was pretty exited to finally be able to download my programs onto my computer as .exe but this really does not do anything. It just creates a bunch of random files.
¯_(ツ)_/¯

Profile icon
NoelB33

Cool

Profile icon
ancoder

the exe file is too big to download i think

Profile icon
chccchchc

python3 dist//main.spec
Traceback (most recent call last):
File "dist//main.spec", line 7, in
a = Analysis(['main.py'],
NameError: name 'Analysis' is not defined
exit status 1

why i got this error

Profile icon
wittgevalentin

Okay, that's right bu I can't download all.

Profile icon
DSAJagat20

when i do the pip installer thing, it doesn't work. It says there is a syntax error. also, My EXE file is one where you can draw, so I'm not sure if this will work for what I want my EXE file to be

Profile icon
JordanDixon1

@DSAJagat20 do you add that to the file or are you typing it into a shell? I haven't used replit in a while but I think it's Ctrl + shift + S

Profile icon
JordanDixon1

@DSAJagat20 This post is kinda old and I'm not home rn, but once I get home on my computer I'm gonna make a new program that will make your python file into an exe automatically.

Profile icon
DSAJagat20
Profile icon
JordanDixon1

@DSAJagat20 It was a living nightmare but I coded the bare minimum with my phone XD Here's the program link, just copy paste your code into file.py https://replit.com/@JordanDixon1/AutoExe#file.py

Profile icon
JordanDixon1

@JordanDixon1 (pretty sure an exception isn't raised if it can't find the file you're talking about yet the program still says "file.py was made into an exe" lol)

Profile icon
DSAJagat20

@JordanDixon1 It's still not working. I am aiming to get the file to run as a downloadable program on mwa computer. can you do that?

Profile icon
JordanDixon1

@DSAJagat20 repl.it is using Linux so whatever you make on repl.it won't run-on windows. You'll have to follow the directions on your own computer (if it's windows)

Profile icon
Alt_Plus_F4

cx_freeze is better imo

Profile icon
NoelB33

I tried this from repl.it and it works, but it’s sort of broken

Profile icon
JordanDixon1

@NoelBryan In order to do it on repl.it go to a new python file, make the file, then press ctrl + shift + s and type in:

pip3 install pyinstaller

This will installer the python 3.0 version of pyinstaller.

Profile icon
NoelB33

@JordanDixon1 that’s what I did, and it wouldn’t work for me so I used pyinstaller --onefile main.py and it worked
Edit: i got it to work your way, I just did something wrong the first time