# Convert Python File to EXE

## How To Convert Python File to EXE

[April 22nd 2020](https://hackernoon.com/archives/2020/04/22)\


![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7hyVJNqhbJ0qGallm%2F-MC7kQj20sd7PeaA5SJZ%2Fimage.png?alt=media\&token=e1fe3242-4dcf-4c92-bdb2-2d4f6b8bfde7)

### Convert Python to EXE 

In this article, you will learn how you can [convert .py file to .exe](https://youtu.be/RBVwvrnvePA?ref=hackernoon.com) file. Follow the below steps for the same.

**Step 1:**\
Install the library pyinstaller.Type below command in the command prompt.

```
pip install pyinstaller
```

**Step 2:**\
Go into the directory where your ‘.py’ file is located.

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7l1Nu8_-H_FC4cAw8%2Fimage.png?alt=media\&token=f1cff437-2c4e-4b2a-8dd1-c5100e6c741b)

**Step 3:**&#x50;ress shift⇧ button and simultaneously right click at the same location. You will get below box.

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7l9uebyuZGj4aHYmj%2Fimage.png?alt=media\&token=94762ca0-59a5-478e-90ba-4c3489b21200)

**Step 4:**&#x43;lick on ‘Open PowerShell window here’.![](https://hackernoon.com/photos/ZPVQiMmCjuUBmhMCYOpLWd0LSBM2-544w3yi2)

You will get a window shown below.

![](https://hackernoon.com/photos/ZPVQiMmCjuUBmhMCYOpLWd0LSBM2-ei5v3yua)

**Step 5:**&#x54;ype the command given below in that PowerShell window.

```
pyinstaller --onefile -w 'filename.py'
```

My ‘.py’ file name is ‘1’.See below:

![](https://hackernoon.com/photos/ZPVQiMmCjuUBmhMCYOpLWd0LSBM2-4m7e3y01)

In case you get an error at this point in the PowerShell window like this:The correction while typing the above command:

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7lgG6ZoibJ1ti-fcq%2Fimage.png?alt=media\&token=9c6d6f3a-500a-41cb-97b7-a7882a0e080f)

The correction while typing the above command:

```
.\pyinstaller --onefile -w 'filename.py'
```

**Step 6:**&#x41;fter typing the command ‘Hit the Enter’.It will take some time to finish the process depending on the size of the file and how big is your project.After the processing has been finished, the window will look as below:

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7lulEa4O_y5T0DA6M%2Fimage.png?alt=media\&token=b343b80e-ea9d-472f-8530-bfe326f0f037)

**Step 7:**\
See the directory it should look like this:

![](https://hackernoon.com/photos/ZPVQiMmCjuUBmhMCYOpLWd0LSBM2-qybo3ymj)

‘build’ folder and ‘1.spec’ is of no use. You can delete these if you want, it will not affect your ‘.exe’ file.

![](https://hackernoon.com/photos/ZPVQiMmCjuUBmhMCYOpLWd0LSBM2-phck3yr6)

**Step 8:**&#x4F;pen ‘dist’ folder above. Here you will get your ‘.exe’ file.

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7mJO4Cn8FFu7446up%2Fimage.png?alt=media\&token=f4506315-593c-4fd9-94d7-0c7b71879a42)

Right-click on the file and check the properties.

![](https://3650666907-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M16IoaANYRvc0I-U9uw%2F-MC7kbVjMSmfipbwQHOP%2F-MC7mNSP8yN9qFg6peT-%2Fimage.png?alt=media\&token=1ade9e74-188c-4d07-ab54-c37b29bfc3ec)

Stay Tuned!_Previously published at http://gajeshsnaik.codes/convert-python-to-exe/_



Reference : [https://hackernoon.com/how-to-convert-python-file-to-exe-r2ac3yqp](https://hackernoon.com/how-to-convert-python-file-to-exe-r2ac3yqp)
