top of page
  • Writer's pictureAbhijeet Srivastav

How to convert Python file to exe?




So you have completed your python project and want to share it to others as an executable file.


Well you landed at the right place.

Their are several methods to that but i found that module named pyinstaller is best at doing this!


This module pack ups all the files and resources into single executable file or an standalone folder according to your needs.


Here i am using Command Prompt to do so, but you can use the inbuilt terminal of your IDE for this purpose it will work fine.


Just make one thing sure that your python interpreter is installed properly and added to path.


Let's get started!


1.Open command prompt and install the module pyinstaller.

pip install pyinstaller

2. Now reach to the destination folder using cd command in windows.


3. Now type the following commands according to your need.

Type this command to get single standalone executable file.

pyinstaller --onefile  "filename.py"

And type this command to get single standalone folder.

pyinstaller "filename.py"

4.Press enter and it will take time in packing up according to the size of the script.



5. Go to the destination where you have stored your project , their you will get the .exe file or folder according to your command.


Well done! Your project is ready to be shared.


TIPS:

1. I would rather suggest to use the terminal of the IDE for the purpose because the virtual environment is already activated in their and you get a view of all the assets of your project, which will remove any chance of error.

Sometimes it happen that due to python not being set in path or virtual environment not being activated throws an error.


2.Be extra care full with the projects including photos, videos and sound.



STAY TUNED FOR MORE!


 


19 views0 comments
bottom of page