Proper Way to Create Executable from PY File

37 Views Asked by At

I'm not able to create a proper self-contained executable from my Python code.

I recently worked on a project. I coded in Python where I've used MySQL. The modules I've used are tkinter, random, customtkinter and connector from mysql. I also use .png images from my own laptop, using them in the PhotoImage function of tkinter.

The problem is I tried to create an executable from the final code, using the pyinstaller command in cmd. The executable was created in the dist folder successfully, and it works. I realised the application won't run if I delete or misplace the other files generated along, that is the dist and build folders. I used --onefile in pyinstaller and it works without the dist and build folders now.

Now my issue is with running the executable in different laptops. I shared the exe file created by --onefile, but running the exe file doesn't work anymore, meaning it is not self-contained (not needing my laptop's software, like MySQL, the data in MySQL, AND the pictures I have in my laptop).

Error that shows when laptop running exe file does not have MySQL server

Error asking for pictures stored in my laptop

How do I make the exe file ACTUALLY self-contained? I want it to be independent in spite of using all the above mentioned stuff.

P.S. Please use simpler words as I don't have much experience with coding.

0

There are 0 best solutions below