Convert Python Script to Executable(.exe) file.

  We create many Python programs daily and also wish to share some with our colleagues or the World. But its obvious that everyone does not have Python installed in their system. So to avoid this problem we need an Executable file which runs without any prerequisite. So we will have to convert .py file to .exe file.


Step1:

Install the library pyinstaller. 

Type below command in the command prompt.

pip install pyinstaller


Step2:

Go to the directory where you saved your Python Script.

Convert .py to .exe
Convert .py to .exe



Step3:

Press Shift button and Right click on mouse simultaneously. Click on "Open Command Window here".


Convert .py to .exe
Convert .py to .exe



Step5:

Type the command in the in the Command Prompt.

pyinstaller --onefile -w 'filename.py'

Here our file name is 'tutorial.py

See below: 

After 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: 

Convert .py to .exe
Convert .py to .exe



Step6:

Your directory should now look like this:

Convert .py to .exe
Convert .py to .exe

      


Step7:

Open the 'dist.' file.

The file you see is your new Executable file.

It should look like this:

Convert .py to .exe
Convert .py to .exe



💨

CONGO YOU CREATED YOUR 1st .exe FILE !



Ready to Solve your Problems in the comment Section !






6 comments:

  1. Leave all your errors & problems here! Gonna solve it together

    ReplyDelete
    Replies
    1. Pip not found error how to resolve?

      Delete
    2. Add your Python bin file in Enviornment variables and restart your pc. It must resolve. If not then tell me in the replies

      Delete

Powered by Blogger.