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!
Related
I have a decently complicated .py script, which uses several packages, incl matplotlib, numpy, and one custom, that is compiled from a fortran code. I want to make a windows executable out of this, that is distributeable in a way, that users don't need to have python installed on their computers for it to work.
When I make my .exe with pyinstaller --onefile myprogram.py the resulting .exe doesn't run on its own (if I doubleclick on it, the GUI it contains doesn't open), however, if I have anaconda installed, from anaconda prompt I can run it with .\path\to\program\myprogram.exe and it works all nicely (without creating an environment with matplotlib etc)
My question is: how can I make it so that the one file includes all the dependencies and I can just doubleclick on it and go?
Thanks in advance!
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.
I am struggling with creating .exe or similar formatted files with my python 3.6 project. I have success with creating an exe using pyinstaller, but it requires me to have installed the module pymysql separately and to include the icon.ico file in the same directory as the new application.
How would I go about creating a standalone executable that not only stores the icon.ico used for the program title icon, and including the pymysql module as well as seperate .py files?
I've tried using different arguments within pyinstaller, and I've looked at py2exe but this doesn't seem to support python 3.6.
I think my question is quite badly phrased, which may be why I haven't been able to find the answer yet.
I created my program in Python, created an installable .exe file from it using bdist_winisnt. Once the program is installed, I would like to be able to run it from anywhere. It's a command line program, so I would like the user to be able to be in a different directory and still be able to type example.py in command line and the program can run.
Is this possible? Is there a way of including some kind of path instruction in the setup.py which will be run on install so that the computer will always know where it is?
I would also like to be able to do this in Linux at some point, will it work the same?
I'm very new to programming, so I may have made some mistakes with what I have said, apologies in advance.
EDIT: turns out there was a really simple way to do it by adding one line to the setup.py file
Good answer to your question is: http://docs.python-guide.org/en/latest/shipping/freezing/
Options are:
bbFreeze
py2exe (supports Python 3)
pyInstaller (does not support Python 3)
cx_Freeze
py2app (Mac)
Your installer only copies the python script to a specified directory.
In order to run a python script you need to have python installed.
You can use a tool like PyInstaller to convert your script (.py file) into an executable (.exe on windows). The way that works is PyInstaller copies both the python interpretor and your script into a single file so that you can distribuite your program easily.
After you have converted your script into an executable, you need to add it to the path so that your operating system knows where to find it. After you do that, you can run your program from the command line from any directory.
The same process will also work on Linux, but you'd have to make separate distributions of the executable because windows executables are different from linux executables.
Check PyInstaller
PyInstaller is promising solution for creation of executables.
I have tested it on Ubuntu, but documentation claims, MS Windows is supported too.
There are multiple options, one of them being single executable file (which include complete 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