Modern Python Projects Transcripts
Chapter: Let's build an app
Lecture: Create a Windows exe file
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
In this and the next lesson we're going to build the gui application using the Windows operating system. I'm running windows 10 on a virtual machine,
0:10
and it's a brand new installation, so I haven't actually configured anything,
0:15
and it's going to be fun to use because I haven't been using Windows since ages and I'm not really sure how things works here,
0:24
but, well, let's give it a try. First, we need to install Python, so let's open the browser. Last time I used Windows,
0:31
it was still using Internet Explorer, and you mostly used it to download the different browser. But I've heard that edge is now much better.
0:41
This is going to be a bit slow. As I said, it's a virtual machine, so I will try to speed up some things to get a Python installation.
0:49
We are going to go to the Python.org website and download the installer From here. You might be wondering why I'm not using pyenv for gui application
1:01
that uses tkinter. The oficial installer will also install some additional bindings for tkinter and I'm not sure if pyenvwin would do that for you.
1:15
You can of course use Still, use pyenvwin. There is nothing wrong with installing one Python version with the
1:21
oficial Python installer and then using pyenvwin to install different Python versions. So that's what I would recommend you to do.
1:31
First time you start using windows, you install the oficial Python version, probably the latest one available, and then you use it to,
1:41
install pyenvwin, and then you use pyenvwind\ to install any additional Python versions. So make sure you click at Python 3.9 to path,
1:57
and I will go through the customized installation, so we can see what's happening. Documentation is not really necessary, but you can leave it.
2:07
This part is very important. Those are the additional dependencies that we will need for
2:13
tkinter, so make sure this is clicked and the rest is up to you Okay, once installation is finished,
2:47
we can probably also click that because it looks important. And now let's grab the files from the host folder.
3:07
So, I go here and let me just copy the whole folder. I have so many files because I have the virtual environment there and we are copying
3:20
all the install packages. I could remove it to make this copying a bit faster but it's too late now, so I'm just going to speed up the video,
3:31
Okay? Once we have that, let me drag this to the middle. Come on. Oh, man. This machine is so slow, let's go inside and clean up a little bit.
3:46
We don't need build. We don't need this. Oh, wronng key. I keep pressing the command key instead of control. No, I don't want to start menu.
3:56
Go away. How do I close it? Okay. Come on. Stop doing that. One by one. No Not this button. Sorry. This this this and this goes away.
4:18
not this button. And inside here, this goes away and the rest stays. And I want to see the hidden files to remove the venv.
4:34
So this goes away. You can see there's a lot of files here. This goes away, this and this goes away, and here everything looks fine. All right,
4:47
so now we have basically the same files that we had when we started this chapter
4:51
Now I have to create a virtual environment and install all the additional packages. So, how did I do this on Windows?
5:02
I guess we have to find a command line. Ha there is. I hope so.
5:20
No, there is, Let's move our files here. So now we should be able to run Python command and have something here. Yes, we do have Python.
5:38
So let's create a virtual environment. And now I have to activate it. So I need to find the equivalent of source command on the windows.
5:51
Let's go inside this folder and see what we have there. I guess I can run the activate.bat
6:10
Yes. Perfect. All right, let's go up and let's install all the dependencies and let's see if we can run
6:31
our guptimer. Okay. Perfect. It's working. Great. That was actually pretty smooth experience so far.
6:46
Okay, let's install pyinstaller and let's try to create a package.
7:03
Once we have that, let's try to build our package. Oops, Different kind of slash. I forgot. We're using backslash here.
7:25
Looks like everything was successful. Awesome.
7:44
We have the gui.exe file and that it's starting our uptimer. Let's make sure that it still works and it does work indeed.
8:04
Great. Let's run pyinstaller one more time to create one file with everything bundled just as we did for macOS. And then in the next video,
8:16
I will use a yet another clean Windows virtual machine, and we'll try to run this package.
8:39
Cool. I have the gui.exe, and it even has the pyinstaller icon. That's so nice. So, now I'm going to take this exe file and move it
8:59
to a clean new Windows installation that doesn't even have Python install, and then we'll check if it still works,
9:06
so I will see you in the next lesson.