Monday, February 5, 2018

Python code to exe (Windows)

PyInstaller helps you convert your python code to executable software package.

Our test environment: Windows 7, Python 3.6

Create your python code file (hello.py)
print("Hello World!")
Download PyInstaller via pip
pip install pyinstaller
Run PyInstaller with python code file parameter on console
"C:\Program Files\Python36\Scripts\pyinstaller.exe" hello.py
You will see some commands on the screen. A few seconds later it will finish building. Build time is dependent your code (referenced packages).

Check dist folder for distribution copy of your application (hello.exe)

Size of the folder for hello.py is around 11mb.

I tried also py file with reference of cv2 library. Build time is around 30seconds and folder size becomes 157mb.

0 comments: