How to make a python script into an executable file

Posted

in

by

To run a python script. You have to open python in either the command prompt or its IDLE.

We can make use of pyinstaller module. Which will take your script and add all the dependencies and create a standalone executable file which you can use just like any other software.

To install pyinstaller

open your command prompt and execute the following code

pip install pyinstaller

This will install pyinstaller .

After doing it. Browse into your script folder.

pyinstaller --onefile your-python-script.py

If you run the above line it will create a self containing executable file.

You can also have a directory in which all the dependency files are placed along with the executable file.

pyinstaller --onedir your-python-script.py

If you do want to have a console.

pyinstaller --onefile --noconsole your-python-script.py

If you want your executable file to have a custom icon. You can put a icon file in the same directory along with your Python script.

pyinstaller --onefile --noconsole -i "icon.ico" your-python-script.py

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *