Learn to Code via Tutorials on Repl.it!

← Back to all posts
How to create EXE's from Python!
h
JordanDixon1 (324)

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!

Commentshotnewtop
James2008 (6)

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.
¯_(ツ)_/¯

Alt_Plus_F4 (6)

cx_freeze is better imo

NoelB33 (314)

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

JordanDixon1 (324)

@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.

NoelB33 (314)

@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