Convert .py to .exe

To convert your python source code to exe, you have to install pyinstaller. For that run cmd (command prompt) as administrator. Once in there, write any of these commands:

pip install pyinstaller
pipx install pyinstaller
sudo easy_install -U pyinstaller
sudo easy_install-x -U pyinstaller

Substitute ‘x’ with your python version, you can also substitute ‘x’ with 2 or 3 if you have Python-2.x or Python-3.x respectively.  For example I have Python-3.5 so I will write them as pip3.5 install pyinstaller or pip3 install pyinstaller or sudo easy_install-3.5 -U pyinstaller.

Once you press enter it should start downloading the required files, and it will automatically install them for you. Now, to convert your .py to .exe, all you have to do in cmd is to open up the file directory where .py is located. For example,

fe

The name of the file I want to convert is ‘Project_1’, now write this command:

pyinstaller Project_1.py

wer

It will convert your file, and will make new folders ‘dist’ and ‘Build’. You can delete the folder with name Build, your exe will be located in folder ‘dist\your_filename’.

Note: to run .exe you need all of the files in that folder.

Advertisements

One Comment Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s