Converting .py to .exe

Hey there!

If you watched our YouTube video in the hopes of getting a tutorial, you were obviously disappointed. But, not all hope is lost. We did learn from our mistakes and prepared a step by step guide for you to follow.

Prerequisites:

Before you start converting your .py into an application, make sure you have the following:

  1. Python version 3.7 or above

  2. A current version of pip

  3. A .py file (It would be a little awkward if you tried converting a .py file when there is no .py file)

STEP 1: Install pyinstaller

The first thing you're going to do is pull up your command prompt. It should look like this:

Now, you're going to type in this command:

pip install pyinstaller

This should install all the dependencies you need.

STEP 2: Move to the directory in which your .py file is

Now this step can differ from user to user. So, go to your file manager and locate in which exact drive and folder your .py file is located. If it is in the C: drive already, you can just skip to the next step. However, if you are like us and you unintentionally keep making life difficult for yourself, you probably didn't put it in a convenient location and now you need to switch your drive.

So, to go from your active directory to a different one, simply type the letter of that directory followed by a colon. For example, to switch to D: drive, you would type:

D:

into your command prompt and that will do the job.

Now go ahead and type the exact folder in which your file is preceded by the letters "cd". The format should resemble this:

cd Miniconda\Twitter Miner

STEP 3: Do the actual conversion

In this particular step, it's probably best to note that your command will work correctly if your .py file has a one word name. (Don't ask why; We have no clue either). You can rename the application after creation but for now, just limit it to one word.

Now type this into your command prompt:

pyinstaller Tweety.py

Tweety.py is what our file was called. You will need to use your own file's name in its place.

STEP 4: Find your .exe

Now, assuming you've done everything right up to this step, your computer should have created the application. This is the moment of truth.

Head over to the folder where your .py file was located through your file manager. You should be able to find a folder called "dist".

Go into that folder and voila! There's your .exe

If you magically stumbled upon this guide and have not watched the video where we struggle with this rather simple process, go ahead and check it out down here:

That's all for today folks. Cya