Cxfreeze a python module into exe

Some times one have to turn python modules into executable files to be distributed into a computer without the Python environment. Normally this would be a pain, but with cx_freeze this has become a breeze.

I’ll just list out the steps here in Windows for reference.

1- Install cx_freeze on your computer. The easiest way to do this is with the following command (note that you have to have pip, which comes prepackaged with Python 3.x).

Ensure that pip and python is on your PATH environmental variable

$>pip install cx_freeze

2- Navigate your command shell to the directory of the module. Say, I have a module emailparser.py in the C:\Users\User\Github\emailutil folder.

use the cd command in your shell to change directories.

3- Use the cx_freeze module to transform your python file to a executable.

Ensure that the directory of your cx_freeze script (most likely in Python\Scripts) is on your PATH

Assuming the same file, emailparser.py, as in (2).

$>cxfreeze emailparser.py

Voila! It’s done. It will be in a folder called dist.

Further documentation here.

 
1
Kudos
 
1
Kudos

Now read this

Aidoru wa tsukkoma reru no ga suki! Volume 1 Prologue

Volume One : Prologue “Alright then, let’s start!” Start what, exactly? I could not stop myself from ranting at the voice that suddenly entered my ears. Being forced to wear these earphones just narrowed down my movement range.... Continue →