Using CX_ Freeze in Python:

Sometimes we need to share the projects we create in Python. For sharing the recipient needs to have the same version of Python generally along with the modules which we have there for the project. This is a tedious job, and we have a couple of options for avoiding this. In the case of Python 2.7, Py2exe is a good choice, and in case of Python 3 we work with cx_freeze for data science projects.

CX_Freeze- Converting from .py to .exe:

It is a set of scripts and modules for freezing of Python scripts into executable. It is similar to py2exe and py2app. But unlike the two mentioned tools it is cross-platform and works on any platform on which Python can work. It is supported in Python 2.7 or higher.

We will install cx_Freeze using pip in the following manner.

Using CX_ Freeze in Python for Data Science - PST Analytics

Now we will parse ‘’ with regex and urllib.

Using CX_ Freeze in Python for Data Science - PST Analytics

A 14 second sleep is added at the end for seeing the output at the end before closing. We will save this file as “”

Using CX_ Freeze in Python for Data Science - PST Analytics

Now let’s create a file “”

We have imported the cx_Freeze setup and the executable and now we will call the setup function. The Python script’s path to be converted will be there as parameter.

  1. name: This us the name we want the executable to be.
  2. Version: It is a version number we want to give.
  3. description: This is the details we want to give. It is optional.
  4. executable: These are the things which we shall convert by using the executable function and the Python script’s path we want to convert as parameter.

We will now open up cmd.exe, or bash or what we have to navigate the directory which has the and the script which we want to convert. Then we will run the following code.

We will now have a build directory. We will find another directory, and within that, we will find the executable. In case all things are correct we will it will parse the search result based on the result of basic from and then it will display the text result in 15 seconds before it closes.

So, to learn more about it in python for data science, you can check this and this as well.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.