Standalone Python EXE Executable - Python Tkinter GUI Tutorial #40
Vložit
- čas přidán 17. 02. 2020
- In this video I'll show you how to turn your Python tKinter program into a standalone executable exe file that you can share with your friends, or sell on your website.
There are many ways to make a .exe file out of a tKinter program. In this video I'll show you the fastest and easiest method using pyinstaller.
Use the flag --windowed, so that black console window won't show up.
perfect! thanks!
You can also just save your file as .pyw it does the same
@@Kroenenprime That only works if you already have python installed on your computer...most people don't.
oohh man thank u so much!
Thanks that was really helpful
Before you turn it into a exe, rename the file to .pyw instead of .py
That will get rid of the command prompt that always shows up
or just use the -w flag when building the exe
I tried this but "Ordinal Not Found" error shows up when I run the exe.
Thank you very much
NO in the pyinstaller just use --noconsole and no console will apear
@@Brimstoned_ i tried to use the --noconsole but windows flagged it as virus. same with -w. no idea why, it works just fine without getting rid of the console.
in order to avoid the "command window" to pop up when you run the executable, you just have to write "-- noconsole" along with the pyinstaller call
This was great!! So straightforward and useful. I was able to build a front end GUI app for my python script at work because of this video. Awesome job man.
Glad it helped!
Thanks for the video and the entire playlist, it has been so helpful! Subscribed and liked!
Glad you're enjoying them!
I watched many parts of the series and its awesome, thank you John!
Glad you're enjoying it!
Yeah, me too
You're a great teacher
I just signed up for the full membership. Thanks for making useful videos.
Thanks for this tutorial, I had been trying to do that since ages. Really appreciate your work.
Glad you liked it
I'm having issues with Windows Defender flagging my exe file as a Trojan. It only seems to happen when I use the --onefile flag, but it defeats some of the purpose of packaging my script if my coworkers have to keep the two directories as they are in order to use the program. Sending one executable file would be much cleaner.
Does anyone have any suggestions?
THANK YOU. I was trying to look up how to make an executable .exe, but the program that you used to make the .exe actually helped me with my program. I had a problem with inputting the text into the same window and the "myLabel = tkinter.Label(root, text) " helped. Thank you!
Glad I could help!
Try to run this 'standalone program' in any other windows computer( if possible except windows10 ) . It does not work for me at least.
Also will it work on other os?
Hey John,
I was successful in creating python exe file, but while using tjr same file on another computer, it got detected as a virus. Basically any exe file which i create is shown as a virus. How can i solve this problem other than adding the file as exception in any antivirus software?
▶️ Watch Entire Tkinter Playlist ✅ Subscribe To My CZcams Channel:
bit.ly/2UFLKgj bit.ly/2IGzvOR
▶️ See More At: ✅ Join My Facebook Group:
Codemy.com bit.ly/2GFmOBz
▶️ Learn to Code at Codemy.com
Take $30 off with coupon code: youtube1
Great tutorial, we can also add '--noconsole' in the command prompt to hide the black window
or simply -w
IT'S ALWAYS THE UNDERRATED VID THAT'S LEGIT! THANK YOU!
Thanks...but I wouldn't call a video with 200,000+ views underrated ;-)
What if our program uses some images ? can we still run the exe file isolated without those ..? since i got an error
You'll have to put that image into the temp directory where the back-end files of stand-alone app are created.
Thank you so much for the info that I can clean up everything besides the main file!
hello, i have a problem with this method when i try to run the program on my other pc
Suuuuuuuuuuuuper helpful tutorial. Thank you John!
Happy to help!
Thanks for this tutorial! Finally my school project has been completed. 🙂
Hi John! Thanks for this! What if I have a picture in my code? Is there a way to specify it as we do with the icon?
Ive tried with --add-data but it doesn't seem to work: pyinstaller.exe --onefile --icon=Icon3.ico --add-data="Image.png;img" PySprings.py
Sir i created a weather app which you shown in 24th video in your playlist but i did some changes adding images of cloud and other weathers but when i try to convert it to exe file its showing error. I think thats probably due to images of clouds and all. Can you tell me command to rectify it.
What about if we have more than one window in our program with more ico files and png files
Hi, I am trying same thing.. But when running in other machine still its again asking me for install modules which I have used in my exe. Please suggest
Did you make a later videos for better ways to do this? Pyinstaller makes the program run really slowly on another computer
wow cant believe I hadn't run across this before. thanks, mate!
Sure thing
hey, great video here helped me alot. However i have a image file in my code, which when i create a .exe it launches but flags a error saying the image can't be found. am i missing something here, in my code i have the 'my_img = ImageTk.PhotoImage (Image.open("image.png"))' which maps to the location of my image in my code and works when operating though python directly. when operate through .exe basiclly says "failed to execute due to unhandled exception: [Errno 2] no such file or directory: 'image.png'
I have a little problem, my app has images taken from an specific directory. If I want to distribute it, people would have to install these images too?. And if so... The python code takes the image from that specific directory, but for the client it would not be the same directory, so it would bring an error. Is there a way to get rid of this problem?
Bitdefender antivirus is detecting the stand alone EXE file as virus and keeps on removing it as soon I create it. Please advise.
What can I do when my python file relies on some external libraries? Would I have to pack the whole library into the .exe file? Thanks!
Pyinstaller has the built in feature to sweep through your python script, find all the import statements, and then copy those libraries during the conversion process
how will this work if my program needs to have atleast multiple scripts? do I just build from my main script?
save the .py file as a .pyw , it runs the exact same as a regular python file but runs without the shell window
Underrated Comment
@@SanyogLamsal not underrated. see other comments
@@DanielMemeSmith This one worked for me.
The computer I coded the .py file on, once turned into an .exe file, still works perfectly, until I move it to another computer for download. When I do so its detected as a virus. I would like to sell software soon so this is an issue I'd love to eliminate. I'm still learning, but to test converting .py into .exe I made a simple calculator program. Not very modern visually and not too many lines of code. But it still is flagged on other computers. Help plz!
You're the best sir ❤️ thanks a lot for this whole playlist
You're very welcome!
Tip: Application won't start without icon next to it on another pc if you use an icon instead of tkinter default icon on its windows, check the path of the icon in python code also
Adding --noconsole does the job perfectly!
Or no exe and just pyw
What if my python project got multiple files linked with eachother?
Please tell me if I have some text file which I am showing in this text widget then how to make exe
I am making a program in the Python language on the Tekinter library, and when I convert the program to an exe file, it does not record with me any record from the printer, while I am running from the editor, the recording takes place, and I do not know where the problem is exactly
What do to if i have many pictures embedded inside my tkinter gui , is it possible to create a standalone for that type of file which contains alot of pics packed ?
Did u figure it out
Is it impossible to save information in an external file with these standalone files? Like settings, etc. I mean, like internally.
Sir I made the app with pyinstaller I opened it in my pc its working totally fine but when I shared only the .exe file of my app to my friend
then in his pc that app is not opening
[He goes in the location where my app is saved and clicks it and installs it and then when he opens only that black command line window appears then after 2-3seconds the command line box disappears and the application window doesn't appears.]
Help me fix the problem sir
Hey elder.. i have done everything, instead of running my exe , it shows error 'unhandled exception' .. what should i do?
hey john I use this method to make an executable file of flashcard app and a flashcard.exe is made but when I run a cmd window pop up and after some seconds it closes showing something traceback type error and the actual file is not run yet
use the -w flag when you compile it
your a boss sir i watched all your videos there amasing sirtenly with your dog
Thank you for the video. Of couse why not using the "--noconsole" argument to the command so it wouldn't create that console?
yes
Hello, I have created an app in Python which must connect to a database, but I want to extract the credentials from the code and make an executable to put it into production. The problem is that one way or another the user has access to the credentials, whether they put them in the code or include the .env file with the executable. Anyway, I don't know what to do to prevent users from having access to the credentials, I would like to know how I can do so that only the app has access to the credentials. Greetings.
if it is a big program (with dashboard and other..mysql), can we run like this..?
pyinstaller -w --onefile --icon=codemy.ico entry_height.py
-w (to avoid cmd console)
Thanks for tutorial man!
Thanks for the video it was a huge help! Now I have made my executable is there a way to update it? I can't seem to find a way to make changes without deleting the exe and installing again with the new source code.
If we import other libraries the converted exe file do not have that libraries
Hi, I come back and see this video because after creating the exe file the tkinter entry dont accept the paste shortcut why is that? and how can I fix it?
like always thank you sir for your great videos
i have questions i write some code to scraping a site. it have button called "get" to do that. i use selenium for scraping when i click on button it run scraping functions while scraping functions is running tkinter window show "not responding" massage what i must do 🤦🏻♂️
again very thanks 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
The .py file I'm trying to change contains sqlite3 and the .exe file created won't work, but when I try it without any of the database stuff the .exe file works. I even tried placing the database file in the same folder as the .exe file but it still doesn't work. Is there something different for sqlite3?
Hi.. I did some programs with tkinter and sqlite3, I have no problems to convert to .exe
In my case, the first time a run the .exe the program create the database file... So the app create the sqlite3 file in the same folder of .exe file... And everything works great.. hope this information can help you.
Just wondering if firebase is supported by pyinstaller because I am struggling to try and convert my .py file with tkinter gcloud and smtplib into a .exe
No idea, sorry
Hey I'm getting the "File not defined" or "File not found" error as I have images and sounds in my python code. How do set the file path of these images in my python code so that the executable works on any other computer?
Use absolute path's In your code, instead of 'file.mp3' type 'c:/whatever/file.mp3' ?
Awesome Sir, This helps a lot.
Glad to hear that
Now using both --windowed and --onefile flags the exe file as a virus!! Anyway to handle that and hide that popup command prompt??
any insight on how to package Selenium with this? Thanks!
The file that I installed needed SQLite database to work, and when I run the project I installed it can't connect to the database, how do I fix this?
i have a json file in my project how can i do it
How can I do that when I use a tkinter GUI and selenium with a dir "User Profile" for my chrome profile?
I keep getting the error "failed to executescript". I tried adding the folder, I tried adding it manually after compiling the .py file to .exe and so on. Nothing worked for me.
Any tip?
sorry I don’t use selenium so I couldn’t say
Thank you Mr. White!
You bet
It's Mr. Elder, what the hell?
wowwww! i just made my first executable file! Thanks.
Awesome!
@زاكي Zaky did you pip install it?
Hey I do belive adding --noconsole when generating the .exe does remove the black console window... I do not tested yet on a computer without python installed but if works let me know!
yep
Does someone know to how to sign the .exe , because I send test files to my friends to beta test and in other computers my program starts SmartScreen of windows or Avast, so i think it might seem like a virus to their computers.
Same
What would happen if the end user doesn't have all the dependencies available in their system? For example, someone downloads the exefile from internet and the user doesn't have phyton installed in the computer; what that still run?
yes
Use thanks for this amazing free content!
My executables only work on the 64 bits version of Windows, how can I make executables for the 32 bits version?
Hi,
Do you know other ways of deploying the application. like moving the exe to the server and calling the exe on client machines, so other users can't decode the exe (as there are ways to decode). considering use of exe in a organization, where i don't want users to see my code (specially credentials used in code like for database connection)
No. Exe is the only way.
sir I did it..but problem is that when I double click on my final .exe file only black window opens not the GUI window
try the -w flag in the command
How to make exe file if i have database?? how can i include db to the end user?/
-w (or --windowed, or --noconsole) This will get rid of the blank CMD from popping up during launch
--name="" This will name the app differently from your . py file
--icon= (note, if you have your images in sub folders you need to use the path to that folder. Example: images/lock.ico
--onefile (this one is hit and miss. Sometimes I do without this one to get app running right)
Sir can I convert py to exe including sqlite3 database imported in my python app?
Do you have now a solution? I face the same problem right now... 11 Months later xD I hope you can help me now haha
Can anyone help?
how to add dependencies to the single .exe?
My program just opens a cmd for a second a closes automaticaly.
No Display is obtained.
Python 3.7.1
PyInstaller 3.6
I also run to the same problem, did you solve it?
Thank You great video
Thanks
Thanks. Well appreciated
You're welcome!
How do i change the icon when using the -m (No console)?
The exe file does not run on another system as the icon file is not present in the other system. Any solution for this?
Getting this error while converting into executable file in mac OS:
Traceback (most recent call last):
File "/usr/local/bin/pyinstaller", line 6, in
from PyInstaller.__main__ import run
File "/usr/local/lib/python3.7/site-packages/PyInstaller/__init__.py", line 45, in
import pkg_resources
File "/usr/local/lib/python3.7/site-packages/pkg_resources.py", line 1479, in
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
(base)
Thanks a lot. Great video and helpful comments who made the black window disappear. It works for me just on 64bit Windows not on 32. Can I fix that somehow? Is there a way to make an APK file out of this?
Is there a way that I can do this even deleting the image file?
my program need a text file to read from ..how to add that file ?
how to add a text file? just save a text file in your directory...
Can someone help as I have already downloaded but the file open and closes in a second .So how do i fix it?
need your help
i created a exe file with pyinstaller but each time i open it close immediately but when i run it from the PyCham IDE it works. please help me convert it into an exe file
Sorry, I don't do pycharm
what should i do and how to use pyinstaller if i have one python file and one folder contain database and other folder contain images??????
does user need to install phyton at thier end or they can use it as a desktop application without installing phyton?
they wont need to install python
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
any help?
I tried to use 'Pandas' and at the moment I click on the .exe file inside 'dist' folder a error message pops up saying 'No module named pandas'. But I have installed pandas on my virtual environment. Somebody any clue that can help me? thanks.
I'm having the same issue with rply
I did all, but when I click on the exe, I have the console only the poo open, then shut off after seconds, I have tkinter and other modules used
Hi there,thanks for your videos. I have a question, im working in a GUI using tkinter, the python file size is 257 KB. When i create executable using pyinstaller, the size of the GUI is 100 MB. What could be the reason?
exe files are bigger. that's common
You must create a virtual environment for your project 🙂
@@7s9n Thank you
@@sinuheso Your welcome 💛
This application can be ran on a computer that hasn't installed Python and set the file path ?
yes
My Command Prompt does not recognize "pip" install unless I am in the directory with pyinstaller. Is that how it's supposed to work? Its seems like in all of the examples they just run "pip install pyinstaller" from wherever.
No, you need to reinstall python. Click the "add python 3.9 to path" box during installation
@@Codemycom That worked, thanks!
Thank you very much sir.
Welcome
Hey John,
Thanks for your videos. I am on vacation leave and started learning Python and Tkinter on my own with the help of some Google searches and CZcams videos such as yours. Your Videos are super great!
In a way, 'thanks for the pandemic lock down'.
Well understand me.
If you type a single - and a w (-w) after you typed the icon+"name".ico that command prompt will not show up.
again, thanks for your videos.
Glad you're enjoying the videos! Yeah -w works.
so what is the professional way to create an executable file ? if pyinstaller isn't the best way ?
Thanks for the course, i really appreciate it, i kind of have a little problem.
ok?
@@Codemycom I lack self-confidence when coding.
@@fcmorena246 it comes with practice
@@Codemycom okay thanks
Sir i have another problem
Yesterday I created a text editing software with pyinstaller, when I run the program it pops up an error.
(Fatal Error Detected
Failed to execute script ...
Thanks for answering
Hey I don't know if pyinstaller works on python 3.6 because I'm getting an error when I try to pip install pyinstaller
it should
hi, is it possible to include an icon in the title bar so that when I create an executable .exe it is incorporated in it without having to carry it around every time? for example if I change pc?
yes, check the docs.
@@Codemycom Thanks for your quick response, I followed your video, the problem lies in the fact that when I create the executable file and move it to another PC, if the .ico file is not present, it also returns an error because it cannot find the path
@@severinmarco exe are stand alone files. Read the docs to learn how to include your icon.