Python/C API project - compile to exe - python

I'm working on project where I am using Python/C API and C++. C++ is used for most part of application, mainly for gui (wxWidgets), while Python is used for calculations on large data sets, e.g. from files. I'm doing it in Visual Studio and when I run the project in IDE everything works fine, like I want it to. Also, the exe file that is created during the launch of the project in the visual studio, when it is in the same folder with the python .py file, also works as it should be. But what I want to achieve is a complete application contained in one exe.
While searching for a solution, I found various possibilities to create an exe from a python file. For example, PyInstaller which I tested for a simple "hello world" python file and it works. However, I don't know and can't find a solution how to combine the exe created in visual with a python file.
In PyInstaller github issues I found that line:
pyinstaller App.py --add-data 'pathtoexe\your.exe;.' --add-binary "pathtodll\your.dll;." --onefile --noconsole --clean
And I typed this into the console:
pyinstaller myPythonFile.py --add-data 'myVisualGeneratedFile.exe;.' --onefile --noconsole --clean
But after that, when I clicked generated exe file, nothing happens.
I hope that someone has done a similar thing before and I can find help here because I'm already losing my mind on it.

According to https://pyinstaller.readthedocs.io/en/stable/usage.html, you should use --add-binary and not --add-data.

Related

How do I run a Python 3.5 program that uses Tkinter on a computer without Python installed?

I have coded a program in Python 3.5 that uses the Tkinter import. I'm trying to figure out a way to run it on computers that don't have Python. First I tried freezing it but I haven't been able to because none of the freezing tools I found support Python 3.5. Then I tried possibly using a online idle but I couldn't find any that support Tkinter. I would prefer to be able to get a .exe file or something similar but if I could run it online that would be good too any ideas?
EDIT
So I have now successfully downloaded PyInstaller using pip. My current problem is when I type this into the console: pyinstaller.exe --onefile --windowed Finder.py
I get this error: 'pyinstaller.exe' is not recognized as an internal or external command,
operable program or batch file.
EDIT
I have now found the pathway to pyinstaller.exe. Now when I try to use it it says Access is denied.
I finally figured it out after about three days of work. Fist I downloaded PyInstaleller in the zipped form and extracted it. Then I put my program in the PyInstaller folder. Then I opened a regular command prompt. I then typed cd then the location of the PyInstaller folder. Finally I typed pyinstaller.py --one file --windowed program.py. Then when I went into the PyInstaller folder there was a folder called program with the .exe file in the dist folder. Thanks everyone for all of your help!
You can use pyinstaller to do that. I think its work fine on linux em linux.
Another option is use py2exe.
Try pyinstaller -F -w Finder.py as the command or you could check out CxFreeze.

PyInstaller 3.3.dev0+1804636 does not exclude source code in exe

i just compiled my main.py using PyInstaller 3.3.dev0+1804636 and Python 2.7.10 and i realised that the .py is included in the .exe. How do i tell PyInstaller to exclude the .py files and only use the .pyc ? It seems to me that PyInstaller needs the .py to look for dependencies, etc. but it somehow includes the .py together with the .exe even though the PyInstaller documentation says that it hides Source Code from the bundle.

Changing icon after compiling (Python)

I'm using Python 2.7, and pyinstaller in order to make an exe.
Everything works just fine, but the exe file's icon is the PyInstaller icon.
Is there a way to change the icon?
I found this : http://www.dreamincode.net/forums/topic/192592-making-an-exe-file-with-pyinstaller/
But don't quite understand it.
Yes, try:
pyinstaller.exe --onefile --windowed --icon=app.ico app.py
Found in this guide. A quick Google search will lead you to tons of .ico files if you need one.

python GUI to EXE with image and modules

I have created a Python GUI and trying to convert it to .exe with py2exe.
i am using following modules wx,matplotlib,numpy,time,serial,random and a .ico image as logo.
i tried create a setup.py file but it didn't work.need help creating setup file to generate .exe of my GUI.
It would be convenient if you could provide some details regarding why the .EXE is not being created. If you can't provide the details then please go through these questions on Stackoverflow, they maybe helpful:
How to build a python package into an exe
Making a standalone .exe file of a python script
Compiling python code into a single exe
Convert Python Script to .exe that will work on all/most versions of Windows
The best thing is to first refer to the official documentation!

File resources in Python

I got few images and one exe file which I would like to bundle inside of the python exe file?
I mean the same or similar way that it could be done in the visual studio:
Please tell me if its possible, if so , how could I access the resources then?
I am using pyinstaller if it does matter.
You can't bundle your resources inside .Net runtime. Visual Studio allows you to bundle your resources inside your project exe not inside .net executable.
Same way you cannot bundle resources like images and exe files inside python.exe but using Pyinstaller you can create your project exe which will include your resources.
To create a single file use --onefile flag while bundling your project. As per Pyinstaller documentation -
"In a --onefile distribution, data files are bundled within the executable and then at runtime extracted into the work directory."
Here is a link for how onefile mode works

Categories