How to Bind Python Code Executable .exe Files with Additional Library Folders

How to Bind Python Code Executable .exe Files with Additional Library Folders

Build executable files for Python code and add data to the .exe file in the form of files or folders using auto-py-to-exe.

Photo by James Harrison on Unsplash

Are you a developer looking to build executable files for your Python code along with adding some data to the .exe file in the form of files or folders? Yes, it is very much possible to solve this via auto-py-to-exe.

To make a simple .exe via your Python code with no links or adding of data via files or folders just follow my previous post.

To solve this problem I expect auto-py-to-exe to be installed in your workstation as shown below:

auto-py-to-exe package

Once you open Auto-py-to-exe the GUI will look like this:

GUI for auto-py-to-exe

You can select the console-based window in the above image (GUI) to make debugging simple in case of any dependency error or link missing because we can see those things mentioned in the cmd logs.

We can select the location of the Python file by clicking upon the browse button as shown below:

browse button in Auto-PY-to-exe

identified the Python script

To make sure that multiple files and folders are contained within a single .exe, we will select the below-highlighted options:

One file and Console based

Let's say we are using Tesseract extracted library, along with poppler for image recognition in our Python script, we can add these extracted folders to our .exe as shown below by clicking upon add folder:

Adding both directories poppler and tesseract folders

Finally, we will select the output directory where the output file will be extracted:

Output directory

The final step will be to convert this Python to Executable by clicking upon the below-highlighted button and start sharing exe’s:

conversion of Python code to exe

Output creation

Happy Coding!

Note: Make sure that you have installed all the Python packages and libraries used in the Python script via pip because auto-py-to-exe will combine all those libraries available in the current machine and later build an exe. If you do not follow this, the exe when given to another machine will throw an error of no module found (with name of relevant library).

For any further Queries or anything related to Automation via Python or DevOps, you can DM me on Linkedin or Instagram id=acanubhav94.

Special credits to my team interns: Kishan and Pratik.

More content at Sign up for our free weekly newsletter. Get exclusive access to writing opportunities and advice in our community Discord.