> For the complete documentation index, see [llms.txt](https://williambenz.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://williambenz.gitbook.io/home/guides/coding/making-an-.exe-with-python.md).

# Making an .exe with Python

How to make a program from a Python file.

So sometimes you may just want to execute your Python code by making an executable(.exe) on Windows or application

We can actually do this extremely simply!

### Video Tutorial:&#x20;

{% embed url="<https://youtu.be/_EK_KifnAU0>" %}

***

### 1. Text Based Tutorial (simple .exe):&#x20;

<pre><code>1. Open your folder with your Python file
2. Shift + Right Click + Open Command Window here
3. Now type in the following -> <a data-footnote-ref href="#user-content-fn-1">"pip install pyinstaller"</a>
</code></pre>

<figure><img src="https://1308567607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSLuGplTdDgb7VQxPIZmr%2Fuploads%2F5NJQTMY20D21VRA1Aev7%2Fimage.png?alt=media&amp;token=dccfcb3a-513e-4fbb-962d-b2da8362ddba" alt="" width="431"><figcaption><p>You should have something like this after installing PyInstaller</p></figcaption></figure>

```
4. After Pyinstaller is installed, in the same folder run the command below:

"pyinstaller --onefile -w [yourfile.py]"

5. Give it around 30 seconds and you should have 2 folders and 2 files. 
You are only interested in dist, click "dist" and there should be [yourfile] application ready to launch.

6. You can now move this Application to anywhere on your computer and it will run.
```

<figure><img src="https://1308567607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSLuGplTdDgb7VQxPIZmr%2Fuploads%2FYh72sdaAd61blILJ3MGy%2Fimage.png?alt=media&amp;token=3e3ad9f4-0804-421f-a811-8f57d87f4005" alt=""><figcaption></figcaption></figure>

***

## [<mark style="color:red;">Stop Wasting Time!</mark>](https://williambenz.gumroad.com/)

Master IT Skills that will help you speed up your IT career! [Click here -> ](https://williambenz.gumroad.com/)&#x20;

***

### 2. Creating a program to distribute for any computer.

Now, if you are a  Software Developer or something similar, you may actually want to distribute your Python program to just install & run (like old games or programs are installed)

We can do this simply & quickly.

```
1. Install NSIS from Google -> https://nsis.sourceforge.io/Download
1a) IMPORTANT: NSIS may show as a False Positive on VirusTotal,
IT'S COMPLETELY UP TO YOU IF YOU TRUST THE DEVELOPERS. I DO NOT TAKE ANY RESPONSIBILITY.

"I DON'T TRUST" = Find/Research some alternative

2. What you actually need to do is follow the 1st step and make an .exe (scroll to simple .exe)
3. After having an exe, make a ZIP( I highlight, ZIP) archive with ALL the files
```

<figure><img src="https://1308567607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSLuGplTdDgb7VQxPIZmr%2Fuploads%2FzvCAC7KuMh4IHFke0JNW%2Fimage.png?alt=media&amp;token=be4f468c-5a43-4f5a-bd64-2cd3a59b40ad" alt=""><figcaption></figcaption></figure>

```
4. Once you have the .ZIP archive, Launch NSIS
5. Click "Installer based on .ZIP file"
6. Add your .ZIP archive to the program
7. Check your options (You can leave them as default, it will be fine)
8. Double check everything and click "Generate"
```

<figure><img src="https://1308567607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSLuGplTdDgb7VQxPIZmr%2Fuploads%2FsLbY6rnsdsOG2iVq7mmy%2Fimage.png?alt=media&amp;token=9ddb42db-94f1-408c-9a56-69fedc25ff07" alt=""><figcaption></figcaption></figure>

```
9. Once NSIS is finished, You should get an application with your Python file name
10. The file created by NSIS is your installer, you can distribute this to any computer
any computer that installs the program, can use the program just like the Developer on their
computer.

11. Go into "dist" folder, there is the application for us. That Application is our final 
program, you can now move that to anywhere on the system and it will execute.
```

<figure><img src="https://1308567607-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSLuGplTdDgb7VQxPIZmr%2Fuploads%2FPzF0yuAtnqZjmaxpxn3T%2Fimage.png?alt=media&amp;token=d60f513e-5b8c-40f0-a0d5-bdc80ecaacb7" alt=""><figcaption><p>After running the installer, go into the "dist" folder, and move that application to wherever you want!</p></figcaption></figure>

***

## [<mark style="color:red;">Stop Wasting Time!</mark>](https://williambenz.gumroad.com/)

Master IT Skills that will help you speed up your IT career! [Click here -> ](https://williambenz.gumroad.com/)

[^1]: Run this in your terminal
