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
Related
I am currently working on "ubuntu 20.04". I have a classifier.py python file. My python file consists of machine learning packages like pandas, Sk learn etc. I have converted the python file (.py) into an executable file (.exe) using "Pyinstaller".
The generated .exe file works perfectly on my PC but when I try on another PC, it is depending on a path from my PC which is not present on the other PC, resulting in not working. The path is like Users/anaconda/lib etc.
Please help me, how can I solve the issue and also provide me with a good alternative like "Pyinstaller", "py2exe" etc wherein the other PC need not install the packages like Pandas, Sk Learn etc.
Is there a way that the other PC need not need even have python installed to run and executable will run along with files that the pyinstaller will create?
Advance Thankyou
I'm trying to convert .py to .exe , but I'm not able to convert it with the help of py2exe in the command line.
I searched on the internet about a py2exe with a GUI frontend and I got the results as:
GUI2EXE (3/5) (The best one I found, but the .exe comes with lots of .dll files and the .exe file is buggy and doesn't work properly.)
H-two-O (2/5) (Waste of time. Doesn't compile any .exe files associated with Tkinter. Very creative and useful for other file formats.)
PytoEXE (1.3/5) (Just as H-two-O , but doesn't compile Tkinter files to .exe)
GP2EXE (?/5) (I didn't try it out. Maybe you can give a view on it.)
PyBuilder (2.7/5) (Reliable, good GUI interface with options but lacks some of the features and compiling speed to that of GUI2EXE.)
PythontoEXE (1.3/5) (Same as PytoEXE)
But these weren't good. I need a compiler better than all of the compilers listed above which can compile Tkinter files to .exe without any bugs.
Here's how I use py2exe. I know this isn't what you're asking for, but according to my experience, it's really annoying until it works. So please hear me out.
Assuming your Python file is called main.py.
New file setup.py (same folder):
from distutils.core import setup
import py2exe
setup(console=['main.py'])
From here, you can create a .bat file in the same folder, or run it from the command line. Either way, you'll be running python setup.py py2exe to compile the code.
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!
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.
I've made my first Python program, using Python 3.2. Now I'm trying to figure out how to make it an executable.
I pretty much only need it for Windows only. I've searched as much as possible and found out that py2exe doesn't support Python 3. cxfreeze does, but I can't figure out how to make a single executable of my program with it. I need it as a portable one-file exe.
Please bear with me as I am a total newcomer :) Any help is appreciated.
You can use cxfreeze to make the executable (and other files it creates), compress them into a *.7z archive using 7-zip, then use 7-ZIP SFX Maker to turn it into a self extracting archive.
When creating the SFX archive, configure it so that the main executable cxfreeze generates runs when the files are extracted. You can also change the archives icon, as well as tell the archive to extract and run from a temporary folder.
When the user runs the exe, the files will extract to the temporary folder and the program will run. To the user, it will behave exactly like a normal exe file.
According to the Python docs, the only program that will package Python3 as an .exe in cx_freeze, and the cx_freeze developer has explicitly stated that he will not support single-file executables (due to the 'dirty hacks' needed, which some anti-malware programs flag as malware).
Comment on the feature request to add Python3 support to py2exe.
You can compare py2exe folder structure with new python3, and make similar. Then you could use SFX idea to store these folders like libraries, python script and interpreter and set script for SFX to just launch your application. As I remember, this is possible in WinRar, and as I think now, in other archivers.