I have a GUI program which has icons and some images and chromedriver.
Now I want to convert the .py file to .exe with having icon, images and the chromedriver inside the exe. How can I achieve this?
I have tried pyinstaller and that works but I have to keep the icons and chromedriver inside the folder where the exe is and then only it would work but I want it to be inside the exe where i can just distribute the exe to my friend without the chromedriver.
Try this
pyinstaller --onefile --windowed --icon=app.ico test.py
Also, add chrome driver in test.spec file,
binaries=[('path\chromedriver.exe', '.')]
Update the spec file, like pyinstaller test.spec.
You can also update the app icon via the spec file.icon='app.ico'
Related
I had no problems creating the executable with pyinstaller on windows. It is a program that has a window made with tkinter and converts files. It seems that the icon of the tkinter window cannot be displayed in Ubuntu or Linux. However, the icon of the executable file in the directory or the icon in the shortcut after execution does not change. Is there any other way other than the --icon option?
I made an app for my friends but I can't make executable file. I tried to use pyinstaler and cx_Freeze but it didn't worked. It creates properly an exe file but It doesn't work. When I try to run executable It pops out empty cmd window and disapears without any error.
Im working on python 3.7.4.
There is code that I used to create exe with cx Freeze:
import cx_Freeze
executables = [cx_Freeze.Executable("GenshinHelper.py")]
cx_Freeze.setup(
name="GenshinHelper",
options={"build_exe": {"packages":["pygame",'datetime'],
"include_files":['img1.jpg','img2.jpg']}},
executables = executables
)
Here is one way t do that;
first install pyinstaller;
pip install pyinstaller
then write this command;
pyinstaller --onefile -w your_file.py
--onefile will convert all the files in your project into a single file.
-w: command prompt (console) will not pop-up when you will run this .exe file. If your app is a console app, then remove -w.
This will convert your file into an .exe file and will run on any other computer without python installed.
More info at https://youtu.be/UZX5kH72Yx4.
I am trying to convert python file to exe file. I've used pyinstaller.
Steps I followed:
I opened the cmd in the folder where is my script
I used the next command: pyinstaller --onefile -w name.py
And I got the below error when I want to open exe. I want to mention that I use selenium to open a Chrome Browser so chromedriver.exe is needed
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.
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.