How to make .exe application from multiple python files - python

I made a tkinter GUI application using python tkinter. It has eight python files which are connected using subprocess. Each python files have their own dependency in their program and several different folders which have the images for the GUI. I want to make only one .exe file from all the folders and files.
Please solve my problem. Thank-you
I tired it using pyinstaller. But the program is showing there's some issues in your program. But I checked it thoroughly. I don't find any problems

Related

Debugging hatch executables generated by project.gui-scripts

I have a question for you that is making me crazy.
I am working on my python package. I'm building my package using hatchling and pyproject.toml and I have also three GUI targets.
To make them I'm using the project.gui-scripts section in the project files and indeed, three exe files are included in the scripts directory after the package installation.
All of a sudden two out of three exe files are not starting at all. If you execute it from CMD, you don't get any error message, nothing. I said all of a sudden because in the past they all used to work.
The third one, instead is still working nicely.
Do you know if there is anything I can do to check what's going wrong? Can I debug those exe files?
Thanks in advance,

Sending Python .exe file to a machine without Python

I've created an executable file using cx_freeze that contains a simple Python script. The .exe file works on my PC (I have Python installed) but is it possible to send it to a colleague, for example, that doesn't have Python on their machine and will it work? The goal is to package useful Python programs and make them available for others to use even if they don't have Python.
I've played around with it a little bit and it doesn't seem to work on non-Python enabled machines. I've sent just the .exe file (didn't work), just the 'build' folder (in a zip file-didn't work) and I've even zipped the whole folder that contains the .py files and the build folder-that also didn't work. However, I thought this was the point of creating the .exe file? Any guidance would be appreciated.
Thanks

How to remove hard coded file paths from python script for creating executable installer?

So I created a fairly intricate python script with a tkinter GUI that creates many user-defined text files and uses them to create and run a batch script as a sub-process which in turn creates multiple XML files that I parse for data and write to a final, single excel file using xlsxwriter.
Bottom line is this script works flawlessly on my personal machine and has file paths hard-coded into it all centered around a root folder on my desktop. For the sake of my machine, this script is great and does what it needs to do. Now, I want to get this distributed to other computers using an installer that removes necessity to have all external dependencies. I see that py2exe is a useful tool for incorporating these modules (like xlsxwriter) but I'm not sure about how to go about creating an installer that gets rid of hard coded file paths.
Essentially, I want to create something that asks the user to select where a certain program is installed on their computer (this path is used to find the location of an exe written to my batch file. For the sake of distribution, assume every computer that is installing my application has this program installed in something like C:\Program Files\Blahblah) and then asks the user where they want to install my program. Since the script creates and destroys many files during its lifetime, I want this folder to basically act like the folder I have on my desktop right now as the "root directory" of my application. I want to know the best practice for implementing and creating an installer for these file paths into my python application to make the script easy to distribute to any computer running Windows. Thanks!

Pack files (.py, .dll)

I'm trying to create a simple game using C++ with Python embedding. The python code is embedded in my C++ code. I used Python/C API for this. Main programm wrote on MFC. My purpose, that programm will be run on computer, where not installed Python. For this I put these files in my .exe directory:
python27.dll
Python27\
DLLs\ (contents of DLLs folder)
Lib\ (contents of Lib folder)
But I want to put these files in my .exe. It's possible? May be I can link my programm with Python together to create single .exe Read many posts, but didn't find solution...
P.S. About py2exe and etc. I know, but it is for create .exe from "clean" Python programm.

Create a desktop icon for a Tkinter script

I have written a python script with a Tkinter GUI. I would like to create a desktop icon that will execute this script so that the end-user (not myself) will be able to double-click the icon and have the GUI load, rather than 'run' the script from the terminal or python shell and then have to F5 from there.
Is there a way to do this? I have googled many arrangements of my question but most answers seem to be normal python scripts, not ones which are Tkinter based.
I am using a Raspberry Pi with Wheezy and Python 2.7
Thanks in advance.
I create executables(icons that I click to start the programs I write) using 'py2exe'. I use windows 7 and I am not sure if it would work for you with Raspberry Pi, but a google search may clear that up for you. I will provide the link below. Basically you end up with a folder with the executable(icon) and also some files, without which the executable won't work. It's unfortunate that you get this extra 'baggage', but it's still handy and the best solution I have come across. I don't think there is a much better way, but I am not 100% on that. Interestingly, I found that you could delete most of these baggage files and the executable would still work, it was trial and error, but it didn't take long. If I want to send the folder to someone, I zip it first.
py2exe is here
If you need a 64 bit binary you can get it here, along with, actually, pretty much every other version. get py2exe here also
Besides creating executable file other option is create simple .bat file:
Open notepad
Enter "C:\ProgramData\Anaconda3\python.exe" "C:\Users\Your ID\script.py"
First part is path to python.exe, second to your python script
save file as .bat file, ex. "open_program.bat"
Now simply double click on saved .bat file icon should open your script.
I like using cx-freeze to convert python scripts to exe.
There is very easy to follow documentation to do this. In short, you create a setup.py script that specifies what libraries and packages you want to include or exclude in your application.
You can then run the build in the console and it will create a build folder, in which will be an Application File. You can create a Desktop short cut using send to and selecting desktop.
Documentation link
You can save the script as a .pyw file so the user can click on the file and the GUi would open

Categories