Changing icon after compiling (Python) - 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.

Related

Python/C API project - compile to exe

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.

Python virtualenv export to windows

I would like you to suggest me some way how non-IT person would install program I created.
So basically I have virtualenv with python with libs. I am looking for some program that would create something (some exe or whatever necessary) that I would just put on usb, and when another human copied it on newly installed windows pc, it would just work. Its going to be PyQT application.
I would easily be able to setup everything, but it needs to be dumb-proof way. Just some 'exe-like' solution that would do everything itself.
Any suggestions would be highly appreciated. If you feel like this is duplicate, please point me into right direction...but all examples I found needed at least little bit of "IT mind".
pyinstaller package is the best one! see : http://www.pyinstaller.org/
with pyinstaller you can convert your .py files to .exe
you should install ( pywin32 pakcage too ), then you can try this ( run this on your commandline ):
pyinstaller.exe --onefile --windowed --icon=app.ico your_app.py
you can find all its commands on : https://pythonhosted.org/PyInstaller/usage.html, https://mborgerson.com/creating-an-executable-from-a-python-script/

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.

Tkinter program converted to .app using PyInstaller closes immediately

I have a Tkinter GUI battleship game application I wrote that I am trying to convert to a .app file so I can run it easily on Mac OS X computers. After cding to the directory with both the main .py file, and all the subfiles (three other python files, a json file, and an icon file), I am executing the following command:
pyinstaller --onefile --windowed --icon favicon.icns --name Battleship battleship.py
This produces two files in the "dist" folder: Battleship and Battleship.app. The Battleship.app has the icon I specified in the command above.
When I run the non .app file (via double-clicking it), a terminal window opens and my Tkinter GUI opens and works (from the little testing I did) flawlessly. However, I would like only the GUI to open, without the terminal.
This is supposedly the purpose of also producing the .app file. However, when I run the .app file (via double-clicking it), it's icon merely bounces a few times in my application bar at the bottom of my screen, and then disappears. No actual window is opened.
How do I make it so when I double-click the .app file, my application's GUI actually opens (without a terminal window)?
Thanks in advance.
Note: I am using Python 3.5.1
RoberR seems like you are missing some necessary packages while building app from pyInstaller, I would suggest your to use:
pyinstaller --onefile --icon favicon.icns --name Battleship battleship.py
it will display your terminal and you would be able to figure out what is happening, in case of missing package please use:
pyinstaller --onefile --hidden-imports=file_name --icon favicon.icns --name Battleship battleship.py
Hope this solves your problems.
It is definitely an issue with Tkinter that crash when using the doubleclick on the .app. The only workaround I found was to use "brew python3" instead of "anaconda python3".
Reposting myself from: https://stackoverflow.com/a/57818744/10143204
There is a few issues with the tcl version that comes with python, discussed here. I've written an script that automatically changes the init.tcl file to the correct version.
N.B. you shouldn't use the --onefile flag as the file directories aren't present, and the script won't work.
cd /path/of/your/app
git clone https://github.com/jacob-brown/TCLChanger.git
pyinstaller --windowed app.py
python TCLChanger/TCLChanger.py
You should now be able to open your app, from the terminal and via double clicking.

Is is possible to use pyinstaller to build the exe with my own icon?

I am using pyinstaller 2.0 and python 2.7 to build a onedir exe from my pyqt application. Everything works well... the exe runs and shows the specified icon in the progam bar, but the icon shown for the exe is still the pyinstaller icon.
Is is possible to use pyinstaller to build the exe with my own icon?
My build command is:
c:\python27\python.exe c:\pyinstaller\pyinstaller.py --noconsole --icon="myprog.ico" --out="C:\out" "C:\out\myprog.py"
I have already tried modifying the exe section of the spec-file to include "icon='myicon.ico'", but that didn't work.
I had the same issue, resolved by installing pywin32

Categories