I used below command to get a custom icon for my .exe file but my custom icon doesnt appear on my exe file even after successful completion of the command :
pyinstaller --noconsole --onefile
--icon="C:\Users\anubhav.jhalani\Desktop\index.ico" run.py
What am I doing wrong here?
Related
I have a python script that contains code to execute the command line. I generated .exe file from this script using pyinstaller. This is the command I use to freezes my python script:
pyinstaller --onefile --noconsole sriptName.py
When I open my exe file. The console still opens and shows the output of the command line executed in my script
How can I hide this console?
When you run PyInstaller on your project, does a .SPEC file also appear?
If so, edit the .SPEC file's exe field like so:
exe = EXE(
...,
console=False,
...
)
Then run PyInstaller on the .SPEC file.
If a .SPEC file didn't appear before, try running PyInstaller on your project without any parameters (so just pyinstaller myProgram.py). A .SPEC file should appear and you can edit it as above and then rerun PyInstaller.
I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop. (I want to send the file to my friend, without him having to install python or any interpreter)
the file is a some-what game that I want to share with friends and family, which are not familiar with coding.
You can simply use Pyinstaller to create a standalone .exe.
Run this from the Windows cmd to create a standalone executable file: pyinstaller.exe --onefile --noconsole --icon=your_image_here.ico app.py
you can install Pyinstaller by using pip
pip install pyinstaller
go to the directory where your file is saved and type:
pyinstaller.exe --onefile --windowed path/to/your/file.py
--onefile (compresses your files into one .exe file)
--windowed (removes the console when you run your file)
path/to/your/file.py (or simply file.py when you want to convert the file in the same directory)
if you have any error using it, remove the --windowed flag and run file.exe on command line to see the error
I am using pyinstaller to compile my programs. I cannot include files with the -i option. It doesn't compile and instead gives an error. The whole compiler crashes. My error code is here: https://pastebin.com/raw/UBTTMmke I was using powershell after I shift+right-clicked the directory in explorer.
Make sure you 'cd' first on your script's folder destination.
Make sure your image file is converted as .ico file and also in your script's folder
Then try compiling your script as:
pyinstaller --onefile --icon Your_logo.ico My_script.py
Also if you want your console not to pop up when the script is running you can use the 'windowed' option:
pyinstaller --onefile --windowed --icon Your_logo.ico My_script.py
I want the command line to not open because a tkinter interface will open.
I am using pyinstaller so it works when python isn't installed. I am using python 3.6.0.
Can I also have it so it is one exe file that doesn't need the other things to run.
To avoid the command line window, add --windowed to your PyInstaller command line.
To create an one-file bundle, add --onefile to your PyInstaller command line.
These are documented in PyInstaller's options. https://pyinstaller.readthedocs.io/en/stable/usage.html#options
I have set the icon for my PyQt application using self.setWindowIcon(QtGui.QIcon('icon.png')) and it works fine when I run my code in PyCharm.
Next I converted my application to one file with PyInstaller:
pyinstaller.exe --onefile --windowed opc.py --name myapps
However, when running the executable the icon is not shown. What am I doing wrong ?
On left site code from PyCharm, on right site from one file (pyinstaller.exe --onefile --windowed opc.py --name myapps).
Why is not the same ?
I want *.png icon because is transparent.
The icon displayed when running an executable on Windows comes from the executable file itself. To bundle an icon with your application you need to specify the icon when building with pyinstaller.exe by passing the --icon parameter. For example:
pyinstaller.exe --onefile --windowed --name myapps --icon=icon.ico opc.py
Note that unlike for setWindowIcon() the icon file must be in .ico format, so you will need to convert it from the .png first.
If you want to use the PyQt call to set the icon you will need to bundle the icon file into the executable, which can be done using a PyInstaller spec file. A walkthrough of the process of creating and modifying the spec file is in this previous answer.